From 1260a9fd7c789ea8e66a77a05860b2a2f3c674b6 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 30 Jul 2013 17:04:09 +0200 Subject: [PATCH 1/4] Complete categorie contact --- htdocs/categories/viewcat.php | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 3cdb5d516f1..dbe83945832 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -125,6 +125,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 == 3) $title=$langs->trans("ContactCategoryShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); @@ -444,6 +445,58 @@ if ($object->type == 3) } } +if($object->type == 4) +{ + $contacts = $object->get_type("socpeople","Contact",'contact',"socpeople"); + if ($contacts < 0) + { + dol_print_error(); + } + else + { + print "
"; + print ''."\n"; + print '\n"; + + if (count($contacts) > 0) + { + $i = 0; + $var=true; + foreach ($contacts as $key => $contact) + { + $i++; + $var=!$var; + print "\t\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; + } + } + else + { + print ""; + } + print "
'.$langs->trans("Contact")."
'; + print $contact->getNomUrl(1,'category'); + print "'; + $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->contact->creer; + if ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + print '
".$langs->trans("ThisCategoryHasNoCustomer")."
\n"; + } +} + llxFooter(); $db->close(); From 44b3ebbeb4c9881dda8847114a52543987b29ffa Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 30 Jul 2013 17:11:42 +0200 Subject: [PATCH 2/4] Contniue categorie on contact --- htdocs/categories/class/categorie.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ee4ff76a008..1e48d484406 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -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'; /** From 60bb59524878b7685b71311e2ec9af4162ef96ab Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 30 Jul 2013 17:24:27 +0200 Subject: [PATCH 3/4] Finnalise categorie contact --- htdocs/categories/class/categorie.class.php | 11 +++++++++++ htdocs/categories/index.php | 1 + htdocs/categories/photos.php | 1 + htdocs/categories/viewcat.php | 7 ++++--- htdocs/langs/en_US/categories.lang | 2 ++ htdocs/langs/fr_FR/categories.lang | 2 ++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 1e48d484406..5224fa2d72e 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -334,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) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index bd293f9febb..0e512cdfcf7 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -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'); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 8a98ff44c01..06345dfb4cb 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -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'); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index dbe83945832..a27d9a1a460 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -125,7 +125,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 == 3) $title=$langs->trans("ContactCategoryShort"); +elseif ($type == 4) $title=$langs->trans("ContactCategoriesShort"); else $title=$langs->trans("Category"); $head = categories_prepare_head($object,$type); @@ -445,6 +445,7 @@ if ($object->type == 3) } } +//Categorie contact if($object->type == 4) { $contacts = $object->get_type("socpeople","Contact",'contact',"socpeople"); @@ -478,7 +479,7 @@ if($object->type == 4) 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->contact->creer; + if ($typeid == 4) $permission=$user->rights->societe->creer; if ($permission) { print ""; @@ -491,7 +492,7 @@ if($object->type == 4) } else { - print "".$langs->trans("ThisCategoryHasNoCustomer").""; + print "".$langs->trans("ThisCategoryHasNoContact").""; } print "\n"; } diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index bddaf125aec..e883ab24ed0 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -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 diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index c14906dd2fb..bf0c646c034 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -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 From 3a2f76512bbaf959db8a3cee6ac2e35c991aba41 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Tue, 30 Jul 2013 17:28:08 +0200 Subject: [PATCH 4/4] Category contact again --- htdocs/categories/viewcat.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a27d9a1a460..da18c5eba76 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -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);