Manage project category

This commit is contained in:
florian HENRY 2016-08-29 10:32:00 +02:00
parent f7c89b0044
commit a4ce756724
11 changed files with 354 additions and 88 deletions

View File

@ -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 '<tr><td>'.$langs->trans("Color").'</td><td>';
print $formother->selectColor($color,'color');
print '</td></tr>';
// Parent category
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $form->select_all_categories($type, $catorigin);

View File

@ -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'&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_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."&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_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/>";
}

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$cat->id.'&type='.$cat->type.'" class="'.$forced_color .'">';
@ -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 = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color .'">';
$linkend='</a>';

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_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');

View File

@ -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").'</td><td>';
print $formother->showColor($object->color);
print '</td></tr>';
print "</table>\n";
print "</div>\n";

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_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 '</td></tr>';
print '</tr>';
print '</table>';
}

View File

@ -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."&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_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."&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_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."&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_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."&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_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."&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_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=".$account->id."'>";

View File

@ -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 '<div class="tmenudiv">';
print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?'':' title="Top menu"').'>';
}
@ -488,7 +488,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
print '</div>'."\n";
print "<!-- End SearchForm -->\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&amp;leftmenu=home", $langs->trans("Dashboard"), 0, 1, '', $mainmenu, 'home');
// Setup
$newmenu->add("/admin/index.php?mainmenu=home&amp;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&amp;leftmenu=admintools", $langs->trans("Sessions"),1);
$newmenu->add('/admin/system/about.php?mainmenu=home&amp;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&amp;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&amp;leftmenu=admintools", $langs->trans("InitAccountancy"), 1, $user->admin);
}
$newmenu->add("/support/index.php?mainmenu=home&amp;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&amp;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&amp;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&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);
}
}
}
@ -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 '<!-- Process menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['level'].' enabled='.$menu_array[$i]['enabled'].', position='.$menu_array[$i]['position'].' -->'."\n";
// Menu niveau 0
@ -1528,7 +1537,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
if ($blockvmenuopened) { print '</div>'."\n"; $blockvmenuopened=false; }
}
}
if ($altok) print '<div class="blockvmenuend"></div>';
}
@ -1541,7 +1550,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
print '</div>'."\n";
print "<!-- End Bookmarks -->\n";
}
return count($menu_array);
}

View File

@ -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

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/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 ' <a href="'.DOL_URL_ROOT.'/societe/soc.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'">'.$langs->trans("AddThirdParty").'</a>';
print '</td></tr>';
}
// Status
if ($status != '')
{
@ -526,7 +547,7 @@ if ($action == 'create' && $user->rights->projet->creer)
print '<input type="hidden" name="opp_percent_not_set" id="opp_percent_not_set" value="'.(GETPOST('opp_percent')!=''?'0':'1').'">';
print '</td>';
print '</tr>';
// Opportunity amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.(GETPOST('opp_amount')!=''?price(GETPOST('opp_amount')):'').'"></td>';
@ -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
@ -566,13 +595,13 @@ if ($action == 'create' && $user->rights->projet->creer)
print '</div>';
print '</form>';
// Change probability from status
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function change_percent()
{
var element = jQuery("#opp_status option:selected");
var element = jQuery("#opp_status option:selected");
var defaultpercent = element.attr("defaultpercent");
/*if (jQuery("#opp_percent_not_set").val() == "") */
jQuery("#opp_percent").val(defaultpercent);
@ -684,7 +713,7 @@ else
else print $text;
print '</td></tr>';
}
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
$array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
@ -722,7 +751,7 @@ else
print '<span id="oldopppercent"></span>';
print '</td>';
print '</tr>';
// Opportunity amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td>';
print '<td><input size="5" type="text" name="opp_amount" value="'.(isset($_POST['opp_amount'])?GETPOST('opp_amount'):(strcmp($object->opp_amount,'')?price($object->opp_amount,0,$langs,1,0):'')).'"></td>';
@ -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
@ -807,7 +850,7 @@ else
print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
if (strcmp($object->opp_percent,'')) print price($object->opp_percent,'',$langs,1,0).' %';
print '</td></tr>';
// Opportunity Amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
if (strcmp($object->opp_amount,'')) print price($object->opp_amount,'',$langs,1,0,0,$conf->currency);
@ -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
@ -861,7 +911,7 @@ else
{
if (jQuery("#opp_percent").val() != \'\' && ! jQuery("#oldopppercent").text()) jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->trans("PreviousValue")).': \'+jQuery("#opp_percent").val()+\' %\');
jQuery("#opp_percent").val(defaultpercent);
}
}
/*init_myfunc();*/
@ -870,8 +920,8 @@ else
});
});
</script>';
}
}
/*
* Boutons actions
*/
@ -895,7 +945,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Modify').'</a></div>';
}
}
// Validate
if ($object->statut == 0 && $user->rights->projet->creer)
{
@ -908,7 +958,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Validate').'</a></div>';
}
}
// Close
if ($object->statut == 1 && $user->rights->projet->creer)
{
@ -921,7 +971,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('Close').'</a></div>';
}
}
// Reopen
if ($object->statut == 2 && $user->rights->projet->creer)
{
@ -934,8 +984,8 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ReOpen').'</a></div>';
}
}
// 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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddDonation").'</a></div>';
}
}
// Clone
if ($user->rights->projet->creer)
{
@ -1002,7 +1052,7 @@ else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotOwnerOfProject").'">'.$langs->trans('ToClone').'</a></div>';
}
}
// Delete
if ($user->rights->projet->supprimer || ($object->statut == 0 && $user->rights->projet->creer))
{

View File

@ -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.='<br>'.$moreinpopup;
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
if ($option != 'nolink')
if ($option != 'nolink')
{
if (preg_match('/\.php$/',$option)) {
$link = '<a href="' . dol_buildpath($option,1) . '?id=' . $this->id . $linkclose;
@ -1066,7 +1066,7 @@ class Project extends CommonObject
}
else dol_print_error($this->db);
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found
if ($mode == 0)
{
$sql.= " AND ec.element_id = p.rowid";
@ -1609,11 +1609,11 @@ class Project extends CommonObject
function load_board($user)
{
global $conf, $langs;
$mine=0; $socid=$user->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;
}
}