diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 8af76ce8647..5ec318aca52 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -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; @@ -259,7 +270,7 @@ if ($user->rights->categorie->creer) print ''.$langs->trans("Color").''; print $formother->selectColor($color,'color'); print ''; - + // Parent category print ''.$langs->trans("AddIn").''; print $form->select_all_categories($type, $catorigin); diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index c347b4863c7..f472570f308 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -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 ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Label + print ''; + + // Third party + print ''; + + // Visibility + print ''; + + // Statut + print ''; + + // Date start + print ''; + + // Date end + print ''; + + 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 '
'.$langs->trans("Ref").''; + // 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 '
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("ThirdParty").''; + if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1, 'project'); + else print' '; + print '
'.$langs->trans("Visibility").''; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("DateStart").''; + print dol_print_date($object->date_start,'day'); + print '
'.$langs->trans("DateEnd").''; + print dol_print_date($object->date_end,'day'); + print '
'; print ''; @@ -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 ""; @@ -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 "
"; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 60e132f3051..e926611ccd4 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -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"; @@ -1029,11 +1048,11 @@ class Categorie extends CommonObject /** - * Returns all categories + * Returns all categories * * @param int $type Type of category * @param boolean $parent Just parent categories if true - * @return array Table of Object Category + * @return array Table of Object Category */ function get_all_categories($type=null, $parent=false) { @@ -1183,7 +1202,7 @@ class Categorie extends CommonObject } } } - + if ($url == '') { $link = '
'; @@ -1196,7 +1215,7 @@ class Categorie extends CommonObject } } $newcategwithpath = preg_replace('/toreplace/', $forced_color, implode($sep, $w)); - + $ways[] = $newcategwithpath; } @@ -1239,8 +1258,8 @@ class Categorie extends CommonObject } /** - * Returns in a table all possible paths to get to the category - * starting with the major categories represented by Tables of categories + * Returns in a table all possible paths to get to the category + * starting with the major categories represented by Tables of categories * * @return array */ @@ -1415,7 +1434,7 @@ class Categorie extends CommonObject $b = hexdec($hex[4].$hex[5]); $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% - } + } $link = ''; $linkend=''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index a2c7186933e..07c586e3b11 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -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'); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index d3b1f8854b9..6da030db893 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -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); @@ -140,7 +141,7 @@ if ($object->id) print $langs->trans("Color").''; - + print "
'.$title.':
'; print $formother->showColor($object->color); print '
\n"; print "\n"; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 25fb000a594..38ff45d043d 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -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); @@ -207,7 +208,7 @@ if ($action == 'edit') $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print ''; - + print ''; print ''; } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index f5cb88f85f4..fdde86ff1f9 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -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 ""; @@ -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 ""; @@ -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 ""; @@ -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 ""; @@ -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 ""; @@ -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 ""; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7b2b131a59e..386328c0929 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -57,13 +57,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $showmode=1; $classname = 'class="tmenu menuhider"'; $idsel='menu'; - + if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode); if (empty($noout)) print_text_menu_entry('', 1, '#', $id, $idsel, $classname, $atarget); if (empty($noout)) print_end_menu_entry($showmode); $menu->add('#', '', 0, $showmode, $atarget, "xxx", ''); } - + // Home $showmode=1; $classname=""; @@ -132,8 +132,8 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! empty($conf->contrat->enabled)) $menuqualified++; if (! empty($conf->ficheinter->enabled)) $menuqualified++; $tmpentry=array( - 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), + 'enabled'=>$menuqualified, + 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)), 'module'=>'propal|commande|supplier_order|contrat|ficheinter'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -343,7 +343,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode function print_start_menu_array() { global $conf; - + print '
'; print '
'."\n"; print "\n"; } - + /** * We update newmenu with entries found into database * -------------------------------------------------- @@ -504,7 +504,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Home - dashboard $newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("Dashboard"), 0, 1, '', $mainmenu, 'home'); - + // Setup $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup'); if (empty($leftmenu) || $leftmenu=="setup") @@ -528,7 +528,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto,1); $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"),1); $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"),1); - + $newmenu->add("/admin/translation.php?mainmenu=home", $langs->trans("Translation"),1); $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"),1); $newmenu->add("/admin/delais.php?mainmenu=home",$langs->trans("Alerts"),1); @@ -568,7 +568,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"),1); $newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools', $langs->trans('About'), 1); - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $langs->load("products"); $newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin); @@ -579,7 +579,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("accountancy"); $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=home&leftmenu=admintools", $langs->trans("InitAccountancy"), 1, $user->admin); } - + $newmenu->add("/support/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("HelpCenter"),1,1,'targethelp'); } @@ -747,7 +747,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire); // Billed is another field. We should add instead a dedicated filter on list. if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("StatusOrderBilled"), 2, $user->rights->fournisseur->commande->lire); - + $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); } @@ -773,7 +773,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200); $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); - + $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); } @@ -910,7 +910,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } } } - + // Salaries if (! empty($conf->salaries->enabled)) { @@ -919,7 +919,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->write); if (empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->read); } - + // Loan if (! empty($conf->loan->enabled)) { @@ -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); + } } } @@ -1338,7 +1347,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $menuArbo = new Menubase($db,'eldy'); $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,(empty($user->societe_id)?0:1),'eldy',$tabMenu); //var_dump($newmenu->liste); // - + // We update newmenu for special dynamic menus if (!empty($user->rights->banque->lire) && $mainmenu == 'bank') // Entry for each bank account { @@ -1410,7 +1419,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $nbentry = count($menu_array); while (findNextEntryForLevel($menu_array, $cursor, $position, $level)) { - + $cursor++; }*/ @@ -1431,7 +1440,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $altok++; $blockvmenuopened=true; $lastopened=true; - for($j = ($i + 1); $j < $num; $j++) + for($j = ($i + 1); $j < $num; $j++) { if (empty($menu_array[$j]['level'])) $lastopened=false; } @@ -1457,7 +1466,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } $url = $shorturl = $menu_array[$i]['url']; - + if (! preg_match("/^(http:\/\/|https:\/\/)/i",$menu_array[$i]['url'])) { $tmp=explode('?',$menu_array[$i]['url'],2); @@ -1465,11 +1474,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $param = (isset($tmp[1])?$tmp[1]:''); // params in url of the menu link // Complete param to force leftmenu to '' to closed opend menu when we click on a link with no leftmenu defined. - if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($menu_array[$i]['mainmenu'])) + if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($menu_array[$i]['mainmenu'])) { $param.=($param?'&':'').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu='; } - if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($menu_array[$i]['mainmenu'])) + if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && empty($menu_array[$i]['mainmenu'])) { $param.=($param?'&':'').'leftmenu='; } @@ -1477,12 +1486,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $url = dol_buildpath($url,1).($param?'?'.$param:''); $shorturl = $shorturl.($param?'?'.$param:''); } - + $url=preg_replace('/__LOGIN__/',$user->login,$url); $shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl); $url=preg_replace('/__USERID__/',$user->id,$url); $shorturl=preg_replace('/__USERID__/',$user->id,$shorturl); - + print ''."\n"; // Menu niveau 0 @@ -1528,7 +1537,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($blockvmenuopened) { print ''."\n"; $blockvmenuopened=false; } } } - + if ($altok) print '
'; } @@ -1541,7 +1550,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu print ''."\n"; print "\n"; } - + return count($menu_array); } diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 976c8a50d93..351a730104f 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -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 diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index fa89e06f398..67463b27222 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -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) { @@ -235,7 +247,7 @@ if (empty($reshook)) if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; @@ -246,7 +258,7 @@ if (empty($reshook)) $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - + if (! $error) { $result=$object->update($user); @@ -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'); + } } } @@ -310,7 +331,7 @@ if (empty($reshook)) if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $langs->load("other"); $upload_dir = $conf->projet->dir_output; $file = $upload_dir . '/' . GETPOST('file'); @@ -377,7 +398,7 @@ if (empty($reshook)) $clone_notes=GETPOST('clone_notes')?1:0; $move_date=GETPOST('move_date')?1:0; $clone_thirdparty=GETPOST('socid','int')?GETPOST('socid','int'):0; - + $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_project_files,$clone_task_files,$clone_notes,$move_date,0,$clone_thirdparty); if ($result <= 0) { @@ -486,7 +507,7 @@ if ($action == 'create' && $user->rights->projet->creer) print '
'.$langs->trans("AddThirdParty").''; print ''; } - + // Status if ($status != '') { @@ -526,7 +547,7 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; print ''; - + // Opportunity amount print ''.$langs->trans("OpportunityAmount").''; print ''; @@ -544,6 +565,14 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; + if($conf->categorie->enabled) { + // Categories + print ''.$langs->trans("Categories").''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PROJECT, '', 'parent', 64, 0, 1); + print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print ""; + } + // Other options $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -566,13 +595,13 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; - + // Change probability from status print ''; - } - + } + /* * Boutons actions */ @@ -895,7 +945,7 @@ else print '
'.$langs->trans('Modify').'
'; } } - + // Validate if ($object->statut == 0 && $user->rights->projet->creer) { @@ -908,7 +958,7 @@ else print '
'.$langs->trans('Validate').'
'; } } - + // Close if ($object->statut == 1 && $user->rights->projet->creer) { @@ -921,7 +971,7 @@ else print '
'.$langs->trans('Close').'
'; } } - + // Reopen if ($object->statut == 2 && $user->rights->projet->creer) { @@ -934,8 +984,8 @@ else print '
'.$langs->trans('ReOpen').'
'; } } - - // Add button to create objects from project + + // Add button to create objects from project if (! empty($conf->global->PROJECT_SHOW_CREATE_OBJECT_BUTTON)) { if (! empty($conf->propal->enabled) && $user->rights->propal->creer) @@ -989,7 +1039,7 @@ else print '
'.$langs->trans("AddDonation").'
'; } } - + // Clone if ($user->rights->projet->creer) { @@ -1002,7 +1052,7 @@ else print '
'.$langs->trans('ToClone').'
'; } } - + // Delete if ($user->rights->projet->supprimer || ($object->statut == 0 && $user->rights->projet->creer)) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index d5765f102d5..3274f164e75 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -54,10 +54,10 @@ class Project extends CommonObject var $date_start; var $date_end; var $date_close; - + var $socid; // To store id of thirdparty var $thirdparty_name; // To store name of thirdparty (defined only in some cases) - + var $user_author_id; //!< Id of project creator. Not defined if shared project. var $user_close_id; var $public; //!< Tell if this is a public or private project @@ -234,7 +234,7 @@ class Project extends CommonObject global $langs, $conf; $error=0; - + // Clean parameters $this->title = trim($this->title); $this->description = trim($this->description); @@ -463,9 +463,9 @@ class Project extends CommonObject function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') { $elements = array(); - + if ($this->id <= 0) return $elements; - + if ($type == 'agenda') { $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; @@ -905,7 +905,7 @@ class Project extends CommonObject if ($moreinpopup) $label.='
'.$moreinpopup; $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; - if ($option != 'nolink') + if ($option != 'nolink') { if (preg_match('/\.php$/',$option)) { $link = 'societe_id; - + $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); - + $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql.= ")"; @@ -1626,33 +1626,33 @@ class Project extends CommonObject //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + $resql=$this->db->query($sql); if ($resql) { $project_static = new Project($this->db); - + $response = new WorkboardResponse(); $response->warning_delay = $conf->projet->warning_delay/60/60/24; $response->label = $langs->trans("OpenedProjects"); if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project'; else $response->url = DOL_URL_ROOT.'/projet/list.php?mode=mine&search_status=1&mainmenu=project'; $response->img = img_object($langs->trans("Projects"),"project"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + $project_static->statut = $obj->status; $project_static->opp_status = $obj->opp_status; $project_static->datee = $this->db->jdate($obj->datee); - + if ($project_static->hasDelay()) { $response->nbtodolate++; } } - + return $response; } else @@ -1661,8 +1661,8 @@ class Project extends CommonObject return -1; } } - - + + /** * Function used to replace a thirdparty id with another one. * @@ -1679,8 +1679,8 @@ class Project extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - - + + /** * Charge indicateurs this->nb pour le tableau de bord * @@ -1689,16 +1689,16 @@ class Project extends CommonObject function load_state_board() { global $conf; - + $this->nb=array(); - + $sql = "SELECT count(u.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as u"; $sql.= " WHERE"; //$sql.= " WHERE u.fk_statut > 0"; //$sql.= " AND employee != 0"; $sql.= " u.entity IN (".getEntity('projet', 1).")"; - + $resql=$this->db->query($sql); if ($resql) { @@ -1716,8 +1716,8 @@ class Project extends CommonObject return -1; } } - - + + /** * Is the project delayed? * @@ -1726,16 +1726,16 @@ class Project extends CommonObject public function hasDelay() { global $conf; - + if (! ($this->statut == 1)) return false; if (! $this->datee) return false; $now = dol_now(); return $this->datee < ($now - $conf->projet->warning_delay); - } + } + - /** * Charge les informations d'ordre info dans l'objet commande * @@ -1762,27 +1762,88 @@ class Project extends CommonObject $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - + if ($obj->fk_user_cloture) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; } - + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->datem); $this->date_cloture = $this->db->jdate($obj->datecloture); } - + $this->db->free($result); - + } else { dol_print_error($this->db); } } - + + /** + * 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; + } + }