Merge pull request #1144 from FHenry/develop

Finnalise categorie contact
This commit is contained in:
Juanjo Menent 2013-07-30 08:39:13 -07:00
commit ba328b8710
6 changed files with 82 additions and 3 deletions

View File

@ -28,6 +28,7 @@
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
/**
@ -333,6 +334,17 @@ class Categorie
$error++;
}
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact";
$sql .= " WHERE fk_categorie = ".$this->id;
if (!$this->db->query($sql))
{
$this->error=$this->db->lasterror();
dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
$error++;
}
}
// Delete category
if (! $error)

View File

@ -50,6 +50,7 @@ if ($type == 0) $title=$langs->trans("ProductsCategoriesArea");
elseif ($type == 1) $title=$langs->trans("SuppliersCategoriesArea");
elseif ($type == 2) $title=$langs->trans("CustomersCategoriesArea");
elseif ($type == 3) $title=$langs->trans("MembersCategoriesArea");
elseif ($type == 4) $title=$langs->trans("ContactsCategoriesArea");
else $title=$langs->trans("CategoriesArea");
$arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js');

View File

@ -94,6 +94,7 @@ if ($object->id)
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort");
$head = categories_prepare_head($object,$type);
dol_fiche_head($head, 'photos', $title, 0, 'category');

View File

@ -72,25 +72,32 @@ if ($id > 0 && $removeelem > 0)
$result = $tmpobject->fetch($removeelem);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
else if ($type==1 && $user->rights->societe->creer)
{
$tmpobject = new Societe($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
else if ($type==2 && $user->rights->societe->creer)
{
$tmpobject = new Societe($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'societe';
}
if ($type == 3 && $user->rights->adherent->creer)
else if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$tmpobject = new Adherent($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'member';
}
else if ($type == 4 && $user->rights->societe->creer) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$tmpobject = new Contact($db);
$result = $tmpobject->fetch($removeelem);
$elementtype = 'contact';
}
$result=$object->del_type($tmpobject,$elementtype);
if ($result < 0) dol_print_error('',$object->error);
@ -125,6 +132,7 @@ if ($type == 0) $title=$langs->trans("ProductsCategoryShort");
elseif ($type == 1) $title=$langs->trans("SuppliersCategoryShort");
elseif ($type == 2) $title=$langs->trans("CustomersCategoryShort");
elseif ($type == 3) $title=$langs->trans("MembersCategoryShort");
elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort");
else $title=$langs->trans("Category");
$head = categories_prepare_head($object,$type);
@ -444,6 +452,59 @@ if ($object->type == 3)
}
}
//Categorie contact
if($object->type == 4)
{
$contacts = $object->get_type("socpeople","Contact",'contact',"socpeople");
if ($contacts < 0)
{
dol_print_error();
}
else
{
print "<br>";
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Contact")."</td></tr>\n";
if (count($contacts) > 0)
{
$i = 0;
$var=true;
foreach ($contacts as $key => $contact)
{
$i++;
$var=!$var;
print "\t<tr ".$bc[$var].">\n";
print '<td class="nowrap" valign="top">';
print $contact->getNomUrl(1,'category');
print "</td>\n";
// Link to delete from category
print '<td align="right">';
$typeid=$object->type;
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
if ($typeid == 1) $permission=$user->rights->societe->creer;
if ($typeid == 2) $permission=$user->rights->societe->creer;
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($typeid == 4) $permission=$user->rights->societe->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$contact->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
print '</td>';
print "</tr>\n";
}
}
else
{
print "<tr ".$bc[false]."><td>".$langs->trans("ThisCategoryHasNoContact")."</td></tr>";
}
print "</table>\n";
}
}
llxFooter();
$db->close();

View File

@ -17,6 +17,7 @@ SuppliersCategoriesArea=Suppliers categories area
CustomersCategoriesArea=Customers categories area
ThirdPartyCategoriesArea=Third parties categories area
MembersCategoriesArea=Members categories area
ContactsCategoriesArea=Contacts categories area
MainCats=Main categories
SubCats=Subcategories
CatStatistics=Statistics
@ -86,6 +87,7 @@ 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.
AssignedToCustomer=Assigned to a customer
AssignedToTheCustomer=Assigned to the customer
InternalCategory=Internal category

View File

@ -17,6 +17,7 @@ SuppliersCategoriesArea=Espace des catégories de tiers fournisseurs
CustomersCategoriesArea=Espace des catégories de tiers clients ou prospects
ThirdPartyCategoriesArea=Espace des catégories de tiers
MembersCategoriesArea=Espace des catégories d'adhérents
ContactsCategoriesArea=Espace des catégories des contacts
MainCats=Catégories principales
SubCats=Sous-catégories
CatStatistics=Statistiques
@ -86,6 +87,7 @@ ThisCategoryHasNoProduct=Cette catégorie ne contient aucun produit.
ThisCategoryHasNoSupplier=Cette catégorie ne contient aucun fournisseur.
ThisCategoryHasNoCustomer=Cette catégorie ne contient aucun client.
ThisCategoryHasNoMember=Cette catégorie ne contient aucun adhérent.
ThisCategoryHasNoContact=Cette catégorie ne contient aucun contact.
AssignedToCustomer=Attribuer à un client
AssignedToTheCustomer=Attribué au client
InternalCategory=Catégorie interne