Merge pull request #5668 from atm-florian/dev_catgeory_project_issue2701

Dev catgeory project issue 2701
This commit is contained in:
Laurent Destailleur 2016-08-29 17:14:56 +02:00 committed by GitHub
commit 64351f3428
12 changed files with 411 additions and 88 deletions

View File

@ -58,6 +58,7 @@ if ($origin)
if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin; if ($type == Categorie::TYPE_CUSTOMER) $idCompanyOrigin = $origin;
if ($type == Categorie::TYPE_MEMBER) $idMemberOrigin = $origin; if ($type == Categorie::TYPE_MEMBER) $idMemberOrigin = $origin;
if ($type == Categorie::TYPE_CONTACT) $idContactOrigin = $origin; if ($type == Categorie::TYPE_CONTACT) $idContactOrigin = $origin;
if ($type == Categorie::TYPE_PROJECT) $idProjectOrigin = $origin;
} }
if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin; 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); header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type);
exit; exit;
} }
else if ($idProjectOrigin)
{
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type);
exit;
}
else else
{ {
header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); 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"))); header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit; 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); header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$type);
exit; exit;

View File

@ -88,6 +88,13 @@ if ($id || $ref)
$dbtablename = 'socpeople&societe'; $dbtablename = 'socpeople&societe';
$fieldid = ! empty($ref)?'ref':'rowid'; $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 // Security check
@ -145,6 +152,13 @@ if (empty($reshook))
$result = $object->fetch($objectid); $result = $object->fetch($objectid);
$elementtype = 'contact'; $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); $cat = new Categorie($db);
$result=$cat->fetch($removecat); $result=$cat->fetch($removecat);
@ -192,6 +206,13 @@ if (empty($reshook))
$result = $object->fetch($objectid); $result = $object->fetch($objectid);
$elementtype = 'contact'; $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); $cat = new Categorie($db);
$result=$cat->fetch($parent); $result=$cat->fetch($parent);
@ -607,6 +628,75 @@ else if ($id || $ref)
formCategory($db,$object,4,$socid, $user->rights->societe->creer); 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'&nbsp;';
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_CUSTOMER) $title = $langs->trans("CustomersProspectsCategoriesShort");
if ($typeid == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoriesShort"); if ($typeid == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCategoriesShort");
if ($typeid == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); if ($typeid == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort");
if ($typeid == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort");
$linktocreate=''; $linktocreate='';
if ($showclassifyform && $user->rights->categorie->creer) 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_CUSTOMER) $title=$langs->trans("CompanyIsInCustomersCategories");
if ($typeid == Categorie::TYPE_MEMBER) $title=$langs->trans("MemberIsInCategories"); if ($typeid == Categorie::TYPE_MEMBER) $title=$langs->trans("MemberIsInCategories");
if ($typeid == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactIsInCategories"); if ($typeid == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactIsInCategories");
if ($typeid == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectIsInCategories");
print "\n"; print "\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$title.':</td></tr>'; 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_CUSTOMER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->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_CONTACT) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removecat=".$cat->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;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_CUSTOMER) $title=$langs->trans("CompanyHasNoCategory");
if ($typeid == Categorie::TYPE_MEMBER) $title=$langs->trans("MemberHasNoCategory"); if ($typeid == Categorie::TYPE_MEMBER) $title=$langs->trans("MemberHasNoCategory");
if ($typeid == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactHasNoCategory"); if ($typeid == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactHasNoCategory");
if ($typeid == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectHasNoCategory");
print $title; print $title;
print "<br/>"; print "<br/>";
} }

View File

@ -50,6 +50,7 @@ class Categorie extends CommonObject
const TYPE_CONTACT = 4; // TODO Replace this value with 'contact' 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_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_ACCOUNT = 5; // for bank account TODO Replace this value with 'account'
const TYPE_PROJECT = 6;
/** /**
* @var array ID mapping from type string * @var array ID mapping from type string
@ -64,6 +65,7 @@ class Categorie extends CommonObject
'contact' => 4, 'contact' => 4,
'user' => 4, 'user' => 4,
'account' => 5, 'account' => 5,
'project' => 6,
); );
/** /**
* @var array Foreign keys mapping from type string * @var array Foreign keys mapping from type string
@ -78,6 +80,7 @@ class Categorie extends CommonObject
'contact' => 'socpeople', 'contact' => 'socpeople',
'user' => 'user', 'user' => 'user',
'account' => 'account', 'account' => 'account',
'project' => 'project',
); );
/** /**
* @var array Category tables mapping from type string * @var array Category tables mapping from type string
@ -92,6 +95,7 @@ class Categorie extends CommonObject
'contact' => 'contact', 'contact' => 'contact',
'user' => 'user', 'user' => 'user',
'account' => 'account', 'account' => 'account',
'project' => 'project',
); );
/** /**
* @var array Object class mapping from type string * @var array Object class mapping from type string
@ -106,6 +110,7 @@ class Categorie extends CommonObject
'contact' => 'Contact', 'contact' => 'Contact',
'user' => 'User', 'user' => 'User',
'account' => 'Account', 'account' => 'Account',
'project' => 'Project',
); );
/** /**
* @var array Object table mapping from type string * @var array Object table mapping from type string
@ -120,6 +125,7 @@ class Categorie extends CommonObject
'contact' => 'socpeople', 'contact' => 'socpeople',
'user' => 'user', 'user' => 'user',
'account' => 'bank_account', 'account' => 'bank_account',
'project' => 'projet',
); );
public $element='category'; public $element='category';
@ -146,6 +152,7 @@ class Categorie extends CommonObject
* @see Categorie::TYPE_CONTACT * @see Categorie::TYPE_CONTACT
* @see Categorie::TYPE_USER * @see Categorie::TYPE_USER
* @see Categorie::TYPE_ACCOUNT * @see Categorie::TYPE_ACCOUNT
* @see Categorie::TYPE_PROJECT
*/ */
var $type; var $type;
@ -514,6 +521,18 @@ class Categorie extends CommonObject
$error++; $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) if (! $error)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_lang"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_lang";

View File

@ -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_MEMBER) $title=$langs->trans("MembersCategoriesArea");
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactsCategoriesArea"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactsCategoriesArea");
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesArea"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesArea");
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesArea");
else $title=$langs->trans("CategoriesArea"); else $title=$langs->trans("CategoriesArea");
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');

View File

@ -101,6 +101,7 @@ if ($object->id)
elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort"); elseif ($type == Categorie::TYPE_MEMBER) $title=$langs->trans("MembersCategoryShort");
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
else $title=$langs->trans("Category"); else $title=$langs->trans("Category");
$head = categories_prepare_head($object,$type); $head = categories_prepare_head($object,$type);

View File

@ -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_MEMBER) $title=$langs->trans("MembersCategoryShort");
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
else $title=$langs->trans("Category"); else $title=$langs->trans("Category");
$head = categories_prepare_head($object,$type); $head = categories_prepare_head($object,$type);

View File

@ -115,6 +115,13 @@ if ($id > 0 && $removeelem > 0)
$result = $tmpobject->fetch($removeelem); $result = $tmpobject->fetch($removeelem);
$elementtype = 'account'; $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); $result=$object->del_type($tmpobject,$elementtype);
if ($result < 0) dol_print_error('',$object->error); 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_MEMBER) $title=$langs->trans("MembersCategoryShort");
elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_CONTACT) $title=$langs->trans("ContactCategoriesShort");
elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title=$langs->trans("AccountsCategoriesShort");
elseif ($type == Categorie::TYPE_PROJECT) $title=$langs->trans("ProjectsCategoriesShort");
else $title=$langs->trans("Category"); else $title=$langs->trans("Category");
$head = categories_prepare_head($object,$type); $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_SUPPLIER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_CUSTOMER) $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_MEMBER) $permission=$user->rights->adherent->creer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$prod->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;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_SUPPLIER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_CUSTOMER) $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_MEMBER) $permission=$user->rights->adherent->creer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;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_SUPPLIER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_CUSTOMER) $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_MEMBER) $permission=$user->rights->adherent->creer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$soc->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;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_SUPPLIER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_CUSTOMER) $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_MEMBER) $permission=$user->rights->adherent->creer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$member->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;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_CUSTOMER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->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_CONTACT) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;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_CUSTOMER) $permission=$user->rights->societe->creer;
if ($typeid == Categorie::TYPE_MEMBER) $permission=$user->rights->adherent->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_ACCOUNT) $permission=$user->rights->banque->configurer;
if ($typeid == Categorie::TYPE_PROJECT) $permission=$user->rights->projet->creer;
if ($permission) if ($permission)
{ {
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$account->id."'>"; print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$account->id."'>";
@ -643,6 +657,61 @@ if ($object->type == Categorie::TYPE_ACCOUNT)
} }
} }
// List of Project
if ($object->type == Categorie::TYPE_PROJECT)
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projects = $object->getObjectsInCateg("project");
if ($projects < 0)
{
dol_print_error($db, $object->error, $object->errors);
}
else
{
print "<br>";
print "<table class='noborder' width='100%'>\n";
print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("Project")."</td></tr>\n";
if (count($projects) > 0)
{
$var=true;
foreach ($projects as $key => $project)
{
$var=!$var;
print "\t<tr ".$bc[$var].">\n";
print '<td class="nowrap" valign="top">';
print $project->getNomUrl(1,0);
print "</td>\n";
print '<td valign="top">'.$project->ref."</td>\n";
print '<td valign="top">'.$project->title."</td>\n";
// Link to delete from category
print '<td align="right">';
$typeid=$object->type;
$permission=0;
if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer);
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_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."&amp;type=".$typeid."&amp;removeelem=".$project->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
print "</tr>\n";
}
}
else
{
print '<tr '.$bc[false].'><td colspan="3" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoProject").'</td></tr>';
}
print "</table>\n";
}
}
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -285,6 +285,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3801__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&amp;action=create', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3801__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks.php?leftmenu=projects&amp;action=create', 'NewTask', 1, 'projects', '$user->rights->projet->creer', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3802__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks/list.php?leftmenu=projects&amp;mode=mine', 'List', 1, 'projects', '$user->rights->projet->lire', '', 2, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3802__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/tasks/list.php?leftmenu=projects&amp;mode=mine', 'List', 1, 'projects', '$user->rights->projet->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3803__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects&amp;mode=mine', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->projet->enabled', __HANDLER__, 'left', 3803__+MAX_llx_menu__, 'project', '', 3800__+MAX_llx_menu__, '/projet/activity/perweek.php?leftmenu=projects&amp;mode=mine', 'NewTimeSpent', 1, 'projects', '$user->rights->projet->lire', '', 2, 3, __ENTITY__);
-- Project - Categories
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3804__+MAX_llx_menu__, 'project', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&amp;type=6', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3805__+MAX_llx_menu__, 'project', '', 3200__+MAX_llx_menu__, '/categories/card.php?action=create&amp;type=6', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__);
-- Tools -- Tools
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3900__+MAX_llx_menu__, 'tools', 'mailing', 8__+MAX_llx_menu__, '/comm/mailing/index.php?leftmenu=mailing', 'EMailings', 0, 'mails', '$user->rights->mailing->lire', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3900__+MAX_llx_menu__, 'tools', 'mailing', 8__+MAX_llx_menu__, '/comm/mailing/index.php?leftmenu=mailing', 'EMailings', 0, 'mails', '$user->rights->mailing->lire', '', 0, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3901__+MAX_llx_menu__, 'tools', '', 3900__+MAX_llx_menu__, '/comm/mailing/card.php?leftmenu=mailing&amp;action=create', 'NewMailing', 1, 'mails', '$user->rights->mailing->creer', '', 0, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->mailing->enabled', __HANDLER__, 'left', 3901__+MAX_llx_menu__, 'tools', '', 3900__+MAX_llx_menu__, '/comm/mailing/card.php?leftmenu=mailing&amp;action=create', 'NewMailing', 1, 'mails', '$user->rights->mailing->creer', '', 0, 0, __ENTITY__);

View File

@ -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/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); $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&amp;type=6", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat');
$newmenu->add("/categories/card.php?action=create&amp;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);
}
} }
} }

View File

@ -14,6 +14,7 @@ CustomersCategoriesArea=Customers tags/categories area
MembersCategoriesArea=Members tags/categories area MembersCategoriesArea=Members tags/categories area
ContactsCategoriesArea=Contacts tags/categories area ContactsCategoriesArea=Contacts tags/categories area
AccountsCategoriesArea=Accounts tags/categories area AccountsCategoriesArea=Accounts tags/categories area
ProjectsCategoriesArea=Projects tags/categories area
SubCats=Subcategories SubCats=Subcategories
CatList=List of tags/categories CatList=List of tags/categories
NewCategory=New tag/category 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 CompanyHasNoCategory=This thirdparty is not in any tags/categories
MemberHasNoCategory=This member is not in any tags/categories MemberHasNoCategory=This member is not in any tags/categories
ContactHasNoCategory=This contact 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 ClassifyInCategory=Add to tag/category
NotCategorized=Without tag/category NotCategorized=Without tag/category
CategoryExistsAtSameLevel=This category already exists with this ref CategoryExistsAtSameLevel=This category already exists with this ref
@ -56,12 +58,14 @@ ProductsCategoriesShort=Products tags/categories
MembersCategoriesShort=Members tags/categories MembersCategoriesShort=Members tags/categories
ContactCategoriesShort=Contacts tags/categories ContactCategoriesShort=Contacts tags/categories
AccountsCategoriesShort=Accounts tags/categories AccountsCategoriesShort=Accounts tags/categories
ProjectsCategoriesShort=Projects tags/categories
ThisCategoryHasNoProduct=This category does not contain any product. ThisCategoryHasNoProduct=This category does not contain any product.
ThisCategoryHasNoSupplier=This category does not contain any supplier. ThisCategoryHasNoSupplier=This category does not contain any supplier.
ThisCategoryHasNoCustomer=This category does not contain any customer. ThisCategoryHasNoCustomer=This category does not contain any customer.
ThisCategoryHasNoMember=This category does not contain any member. ThisCategoryHasNoMember=This category does not contain any member.
ThisCategoryHasNoContact=This category does not contain any contact. ThisCategoryHasNoContact=This category does not contain any contact.
ThisCategoryHasNoAccount=This category does not contain any account. ThisCategoryHasNoAccount=This category does not contain any account.
ThisCategoryHasNoProject=This category does not contain any project.
CategId=Tag/category id CategId=Tag/category id
CatSupList=List of supplier tags/categories CatSupList=List of supplier tags/categories
CatCusList=List of customer/prospect 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 CatSupLinks=Links between suppliers and tags/categories
CatCusLinks=Links between customers/prospects and tags/categories CatCusLinks=Links between customers/prospects and tags/categories
CatProdLinks=Links between products/services and tags/categories CatProdLinks=Links between products/services and tags/categories
CatProJectLinks=Links between projects and tags/categories
DeleteFromCat=Remove from tags/category DeleteFromCat=Remove from tags/category
ExtraFieldsCategories=Complementary attributes ExtraFieldsCategories=Complementary attributes
CategoriesSetup=Tags/categories setup CategoriesSetup=Tags/categories setup

View File

@ -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/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.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.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$langs->load("projects"); $langs->load("projects");
$langs->load('companies'); $langs->load('companies');
@ -170,6 +171,17 @@ if (empty($reshook))
setEventMessages($langs->trans($object->error), null, 'errors'); setEventMessages($langs->trans($object->error), null, 'errors');
$error++; $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) if (! $error)
{ {
@ -254,6 +266,15 @@ if (empty($reshook))
{ {
$error++; $error++;
setEventMessages($object->error, $object->errors,'errors'); 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 '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.$_POST["description"].'</textarea>';
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_PROJECT, '', 'parent', 64, 0, 1);
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
}
// Other options // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $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 '<textarea name="description" wrap="soft" class="centpercent" rows="'.ROWS_3.'">'.$object->description.'</textarea>';
print '</td></tr>'; 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 // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $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 nl2br($object->description);
print '</td></tr>'; 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 // Other options
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook

View File

@ -1784,5 +1784,65 @@ 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
*/
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;
}
} }