From 1f0adfaff57b7fd578567160a7f20fd27364b501 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 21 Apr 2013 23:44:33 +0200 Subject: [PATCH] Can remove an element from category when on category view. --- htdocs/adherents/class/adherent.class.php | 7 +- htdocs/categories/categorie.php | 7 +- htdocs/categories/class/categorie.class.php | 1 + htdocs/categories/viewcat.php | 121 +++++++++++++++++--- htdocs/product/class/product.class.php | 4 + htdocs/societe/class/societe.class.php | 11 +- 6 files changed, 133 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 87a9b14877e..13a6bdea810 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1520,7 +1520,12 @@ class Adherent extends CommonObject $lien = ''; $lienfin=''; } - + if ($option == 'category') + { + $lien = ''; + $lienfin=''; + } + $picto='user'; $label=$langs->trans("ShowMember"); diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index ddc7079c786..ec2a2b49d63 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -99,7 +99,7 @@ $error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->e if (empty($reshook)) { - //Suppression d'un objet d'une categorie + // Remove element from category if ($removecat > 0) { if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -113,17 +113,20 @@ if (empty($reshook)) { $object = new Societe($db); $result = $object->fetch($objectid); + $elementtype = 'fournisseur'; } if ($type==2 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); + $elementtype = 'societe'; } if ($type == 3 && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; $object = new Adherent($db); $result = $object->fetch($objectid); + $elementtype = 'member'; } $cat = new Categorie($db); $result=$cat->fetch($removecat); @@ -507,7 +510,7 @@ function formCategory($db,$object,$typeid,$socid=0) //print $c->getNomUrl(1); print img_object('','category').' '.$way.""; - // Lien supprimer + // Link to delete from category print ''; $permission=0; if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 96c111f2dc0..377c06fd8d8 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -420,6 +420,7 @@ class Categorie $sql .= " WHERE fk_categorie = ".$this->id; $sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id; + dol_syslog(get_class($this).'::del_type sql='.$sql); if ($this->db->query($sql)) { return 1; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index f174f5f4a60..57cffd387de 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -36,6 +36,7 @@ $ref=GETPOST('ref'); $type=GETPOST('type'); $action=GETPOST('action'); $confirm=GETPOST('confirm'); +$removeelem = GETPOST('removeelem','int'); if ($id == "") { @@ -61,6 +62,40 @@ $type=$object->type; * Actions */ +// Remove element from category +if ($id > 0 && $removeelem > 0) +{ + if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) + { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $tmpobject = new Product($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'product'; + } + if ($type==1 && $user->rights->societe->creer) + { + $tmpobject = new Societe($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'fournisseur'; + } + if ($type==2 && $user->rights->societe->creer) + { + $tmpobject = new Societe($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'societe'; + } + 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'; + } + + $result=$object->del_type($tmpobject,$elementtype); + if ($result < 0) dol_print_error('',$object->error); +} + if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { if ($object->delete($user) >= 0) @@ -214,7 +249,7 @@ if ($object->type == 0) { print "
"; print "\n"; - print '\n"; + print '\n"; if (count($prods) > 0) { @@ -224,10 +259,24 @@ if ($object->type == 0) $var=!$var; print "\t\n"; print '\n"; + print $prod->getNomUrl(1,'category'); + print "\n"; print '\n"; + // Link to delete from category + print ''; print "\n"; } } @@ -249,8 +298,8 @@ if ($object->type == 1) else { print "
"; - print "
'.$langs->trans("ProductsAndServices")."
'.$langs->trans("ProductsAndServices")."
'; - if ($prod->type == 1) print img_object($langs->trans("ShowService"),"service"); - else print img_object($langs->trans("ShowProduct"),"product"); - print " ".$prod->ref."'.$prod->libelle."'; + $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 ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + print '
\n"; - print "\n"; + print '
".$langs->trans("Suppliers")."
'."\n"; + print '\n"; if (count($socs) > 0) { @@ -261,9 +310,24 @@ if ($object->type == 1) print "\t\n"; print '\n"; - + // Link to delete from category + print ''; + print "\n"; } } @@ -285,8 +349,8 @@ if($object->type == 2) else { print "
"; - print "
'.$langs->trans("Suppliers")."
'; - print $soc->getNomUrl(1); + print $soc->getNomUrl(1,'category_supplier'); 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 ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + print '
\n"; - print "\n"; + print '
".$langs->trans("Customers")."
'."\n"; + print '\n"; if (count($socs) > 0) { @@ -298,9 +362,23 @@ if($object->type == 2) $var=!$var; print "\t\n"; print '\n"; - + // Link to delete from category + print ''; print "\n"; } } @@ -326,7 +404,7 @@ if ($object->type == 3) { print "
"; print "
'.$langs->trans("Customers")."
'; - print $soc->getNomUrl(1); + print $soc->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 ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + print '
\n"; - print '\n"; + print '\n"; if (count($prods) > 0) { @@ -336,10 +414,25 @@ if ($object->type == 3) $var=!$var; print "\t\n"; print '\n"; print '\n"; print '\n"; + // Link to delete from category + print '\n"; } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a8803d6e5e8..3d5749169ad 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2412,6 +2412,10 @@ class Product extends CommonObject $lien = ''; $lienfin=''; } + else if ($option == 'category') + { + $lien = ''; + } else { $lien = ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index d6666495a14..0c1b8016938 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1455,6 +1455,15 @@ class Societe extends CommonObject { $lien = 'canvas)?'&canvas='.$this->canvas:'').'">'; + $lien.=(!empty($this->canvas)?'&canvas='.$this->canvas:'').'">'; $lienfin=''; if ($withpicto) $result.=($lien.img_object($langs->trans("ShowCompany").': '.$name,'company').$lienfin);
'.$langs->trans("Member")."
'.$langs->trans("Member")."
'; - print $member->getNomUrl(1); + $member->ref=$member->login; + print $member->getNomUrl(1,0,'category'); print "'.$member->lastname."'.$member->firstname."'; + $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 ($permission) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } print "