diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7604c4fe02cfe169bad6f1189e5c275ead77126c..5c950b06e1325eca84a29effdbef6062e496c4f1 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1580,7 +1580,7 @@ class Adherent extends CommonObject $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $link=''; $linkend=''; - if ($option == 'card') + if ($option == 'card' || $option == 'category') { $link = '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id.$linkclose; $linkend='</a>'; @@ -1590,12 +1590,6 @@ class Adherent extends CommonObject $link = '<a href="'.DOL_URL_ROOT.'/adherents/card_subscriptions.php?rowid='.$this->id.$linkclose; $linkend='</a>'; } - if ($option == 'category') - { - $type = Categorie::TYPE_MEMBER; - $link = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type='.$type.$linkclose; - $linkend='</a>'; - } $picto='user'; diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index 5ec318aca526a0cda1ab5c1885f701ff042ba5d3..19e4047c078af0ca0f87a338b1c7428022d00001 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -89,17 +89,17 @@ if ($action == 'add' && $user->rights->categorie->creer) } else if ($idProdOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&type='.$type); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type); exit; } else if ($idCompanyOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&type='.$type); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type); exit; } else if ($idSupplierOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&type='.$type); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type); exit; } else if ($idMemberOrigin) @@ -107,11 +107,6 @@ if ($action == 'add' && $user->rights->categorie->creer) header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type); exit; } - else if ($idCatOrigin) - { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&type='.$type); - exit; - } else if ($idContactOrigin) { header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type); @@ -179,37 +174,32 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr } else if ($idProdOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?id='.$idProdOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProdOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } else if ($idCompanyOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idCompanyOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCompanyOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } else if ($idSupplierOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idSupplierOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } else if ($idMemberOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type); - exit; - } - else if ($idCatOrigin) - { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idMemberOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } else if ($idContactOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } else if ($idProjectOrigin) { - header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); + header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idProjectOrigin.'&type='.$type.'&mesg='.urlencode($langs->trans("CatCreated"))); exit; } diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php deleted file mode 100644 index f472570f3087789e9e9ef87242cd26287321718c..0000000000000000000000000000000000000000 --- a/htdocs/categories/categorie.php +++ /dev/null @@ -1,832 +0,0 @@ -<?php -/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com> - * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> - * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> - * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** - * \file htdocs/categories/categorie.php - * \ingroup category - * \brief Page to show category tab - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - -$langs->load("categories"); -$langs->load("products"); - -$socid = GETPOST('socid','int'); -$id = GETPOST('id','int'); -$ref = GETPOST('ref'); -$type = GETPOST('type'); - -$removecat = GETPOST('removecat','int'); -$parent=GETPOST('parent','int'); - -$dbtablename = ''; - - -// For categories on third parties -if (! empty($socid)) $id = $socid; -if (! isset($type)) $type = Categorie::TYPE_PRODUCT; -if ($type == Categorie::TYPE_SUPPLIER || $type == Categorie::TYPE_CUSTOMER) $socid = $id; - -if ($id || $ref) -{ - if ($type == Categorie::TYPE_PRODUCT) { - $elementtype = 'product'; - $objecttype = 'produit|service&categorie'; - $objectid = isset($id)?$id:(isset($ref)?$ref:''); - $dbtablename = 'product'; - $fieldid = isset($ref)?'ref':'rowid'; - } - elseif ($type == Categorie::TYPE_SUPPLIER) { - $elementtype = 'fournisseur'; - $objecttype = 'societe&categorie'; - $objectid = isset($id)?$id:(isset($socid)?$socid:''); - $dbtablename = '&societe'; - $fieldid = 'rowid'; - } - elseif ($type == Categorie::TYPE_CUSTOMER) { - $elementtype = 'societe'; - $objecttype = 'societe&categorie'; - $objectid = isset($id)?$id:(isset($socid)?$socid:''); - $dbtablename = '&societe'; - $fieldid = 'rowid'; - } - elseif ($type == Categorie::TYPE_MEMBER) { - $elementtype = 'member'; - $objecttype = 'adherent&categorie'; - $objectid = isset($id)?$id:(isset($ref)?$ref:''); - $dbtablename = 'adherent'; - $fieldid = ! empty($ref)?'ref':'rowid'; - } - elseif ($type == Categorie::TYPE_CONTACT) { - $elementtype = 'societe'; - $objecttype = 'contact'; - $objectid = isset($id)?$id:(isset($ref)?$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 -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid); - -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('categorycard','globalcard')); - - -/* - * Actions - */ - -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - -if (empty($reshook)) -{ - // Remove element from category - if ($removecat > 0) - { - if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) - { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $object = new Product($db); - $result = $object->fetch($id, $ref); - $elementtype = 'product'; - } - if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) - { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $object = new Fournisseur($db); - $result = $object->fetch($objectid); - $elementtype = 'fournisseur'; - } - if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) - { - $object = new Societe($db); - $result = $object->fetch($objectid); - $elementtype = 'societe'; - } - if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $object = new Adherent($db); - $result = $object->fetch($objectid); - $elementtype = 'member'; - } - if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) - { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $object = new Contact($db); - $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); - - $result=$cat->del_type($object,$elementtype); - if ($result < 0) - { - setEventMessages($cat->error, $cat->errors, 'errors'); - } - } - - // Add object into a category - if ($parent > 0) - { - if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) - { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - $object = new Product($db); - $result = $object->fetch($id, $ref); - $elementtype = 'product'; - } - if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) - { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; - $object = new Fournisseur($db); - $result = $object->fetch($objectid); - $elementtype = 'fournisseur'; - } - if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) - { - $object = new Societe($db); - $result = $object->fetch($objectid); - $elementtype = 'societe'; - } - if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $object = new Adherent($db); - $result = $object->fetch($objectid); - $elementtype = 'member'; - } - if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) - { - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $object = new Contact($db); - $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); - - $result=$cat->add_type($object,$elementtype); - if ($result >= 0) - { - setEventMessages($langs->trans("WasAddedSuccessfully",$cat->label), null, 'mesgs'); - } - else - { - if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); - } - else - { - setEventMessages($cat->error, $cat->errors, 'errors'); - } - } - } -} - - -/* - * View - */ - -$form = new Form($db); - - -/* - * Fiche categorie de client et/ou fournisseur - */ -if ($socid) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $langs->load("companies"); - if (! empty($conf->notification->enabled)) $langs->load("mails"); - - $soc = new Societe($db); - $result = $soc->fetch($socid); - - $title=$langs->trans("Category"); - if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$soc->name." - ".$title; - llxHeader("",$title); - - // Show tabs - $head = societe_prepare_head($soc); - - dol_fiche_head($head, 'category', $langs->trans("ThirdParty"),0,'company'); - - print '<table class="border" width="100%">'; - - print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">'; - print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom','','&type='.$type); - print '</td></tr>'; - - // Alias names (commercial, trademark or alias names) - print '<tr><td valign="top">'.$langs->trans('AliasNames').'</td><td colspan="3">'; - print $soc->name_alias; - print "</td></tr>"; - - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>'; - } - - if ($soc->client) - { - print '<tr><td>'; - print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $soc->code_client; - if ($soc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; - print '</td></tr>'; - } - - if ($soc->fournisseur) - { - print '<tr><td>'; - print $langs->trans('SupplierCode').'</td><td colspan="3">'; - print $soc->code_fournisseur; - if ($soc->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; - print '</td></tr>'; - } - - if (! empty($conf->barcode->enabled)) - { - print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3">'.$soc->barcode.'</td></tr>'; - } - - // Address - print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">'; - dol_print_address($soc->address,'gmap','thirdparty',$soc->id); - print '</td></tr>'; - - // Zip / Town - print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->zip."</td>"; - print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->town."</td></tr>"; - - // Country - if ($soc->country) - { - print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; - //$img=picto_from_langcode($soc->country_code); - $img=''; - print ($img?$img.' ':''); - print $soc->country; - print '</td></tr>'; - } - - // EMail - print '<tr><td>'.$langs->trans('EMail').'</td><td colspan="3">'; - print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL'); - print '</td></tr>'; - - // Web - print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3">'; - print dol_print_url($soc->url); - print '</td></tr>'; - - // Phone - print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->phone,$soc->country_code,0,$soc->id,'AC_TEL').'</td>'; - print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->country_code,0,$soc->id,'AC_FAX').'</td></tr>'; - - print '</table>'; - - dol_fiche_end(); - - if ($soc->client) formCategory($db,$soc,2,$socid,$user->rights->societe->creer); - - if ($soc->client && $soc->fournisseur) print '<br><br>'; - - if ($soc->fournisseur) formCategory($db,$soc,1,$socid,$user->rights->societe->creer); -} -else if ($id || $ref) -{ - if ($type == Categorie::TYPE_PRODUCT) - { - $langs->load("products"); - - /* - * Category card for product - */ - require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - - // Product - $product = new Product($db); - $result = $product->fetch($id, $ref); - - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type== Product::TYPE_SERVICE?'service':'product'); - dol_fiche_head($head, 'category', $titre,0,$picto); - - - print '<table class="border" width="100%">'; - - // Ref - print "<tr>"; - print '<td width="15%">'.$langs->trans("Ref").'</td><td>'; - print $form->showrefnav($product,'ref','',1,'ref'); - print '</td>'; - print '</tr>'; - - // Label - print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->label.'</td>'; - print '</tr>'; - - // Status (to sell) - print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>'; - print $product->getLibStatut(2,0); - print '</td></tr>'; - - // Status (to buy) - print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>'; - print $product->getLibStatut(2,1); - print '</td></tr>'; - - print '</table>'; - - dol_fiche_end(); - - formCategory($db,$product,0,$socid,($user->rights->produit->creer || $user->rights->service->creer)); - } - - if ($type == Categorie::TYPE_MEMBER) - { - $langs->load("members"); - - /* - * Category card for member - */ - require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; - - // Produit - $member = new Adherent($db); - $result = $member->fetch($id, $ref); - - $membert = new AdherentType($db); - $membert->fetch($member->typeid); - - llxHeader("","",$langs->trans("Member")); - - - $head=member_prepare_head($member); - $titre=$langs->trans("Member"); - $picto='user'; - dol_fiche_head($head, 'category', $titre,0,$picto); - - $rowspan=5; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; - if (! empty($conf->societe->enabled)) $rowspan++; - - print '<table class="border" width="100%">'; - - // Ref - print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; - print '<td class="valeur">'; - print $form->showrefnav($member,'id','','1','rowid','ref','','&type='.$type); - print '</td></tr>'; - - // Login - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { - print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$member->login.' </td></tr>'; - } - - // Morphy - print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$member->getmorphylib().'</td>'; - /*print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">'; - print $form->showphoto('memberphoto',$member); - print '</td>';*/ - print '</tr>'; - - // Type - print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n"; - - // Company - print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$member->societe.'</td></tr>'; - - // Civility - print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$member->getCivilityLabel().' </td>'; - print '</tr>'; - - // Lastname - print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$member->lastname.' </td>'; - print '</tr>'; - - // Firstname - print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$member->firstname.' </td>'; - print '</tr>'; - - // Status - print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$member->getLibStatut(4).'</td></tr>'; - - print '</table>'; - - dol_fiche_end(); - - formCategory($db,$member,3,0,$user->rights->adherent->creer); - } - if ($type == Categorie::TYPE_CONTACT) - { - $langs->load("contact"); - - /* - * Category card for contact - */ - require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - - // Produit - $object = new Contact($db); - $result = $object->fetch($id, $ref); - $object->fetch_thirdparty(); - - llxHeader("","",$langs->trans("Contact")); - - - $head=contact_prepare_head($object); - $titre=$langs->trans("ContactsAddresses"); - $picto='contact'; - dol_fiche_head($head, 'category', $titre,0,$picto); - - $rowspan=5; - if (! empty($conf->societe->enabled)) $rowspan++; - - print '<table class="border" width="100%">'; - - // Ref - print '<tr><td width="20%">'.$langs->trans("Ref").'</td>'; - print '<td class="valeur">'; - print $form->showrefnav($object,'rowid'); - print '</td></tr>'; - - // Name - print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>'; - print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>'; - - // Company - if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) - { - print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'; - if (!empty($object->thirdparty->id)) - { - print $object->thirdparty->getNomUrl(1); - } - else - { - print $langs->trans("ContactNotLinkedToCompany"); - } - print '</td></tr>'; - } - - // Civility - print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">'; - print $object->getCivilityLabel(); - print '</td></tr>'; - - // Role - print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3">'.$object->poste.'</td>'; - - // Address - print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">'; - dol_print_address($object->address,'gmap','contact',$object->id); - print '</td></tr>'; - - // Zip/Town - print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'; - print $object->zip; - if ($object->zip) print ' '; - print $object->town.'</td></tr>'; - - // Country - print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">'; - $img=picto_from_langcode($object->country_code); - if ($img) print $img.' '; - print $object->country; - print '</td></tr>'; - - // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) - { - print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$object->state.'</td>'; - } - - // Phone - print '<tr><td>'.$langs->trans("PhonePro").'</td><td>'.dol_print_phone($object->phone_pro,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td>'; - print '<td>'.$langs->trans("PhonePerso").'</td><td>'.dol_print_phone($object->phone_perso,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td></tr>'; - - print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($object->phone_mobile,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td>'; - print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($object->fax,$object->country_code,$object->id,$object->socid,'AC_FAX').'</td></tr>'; - - // Email - print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($object->email,$object->id,$object->socid,'AC_EMAIL').'</td>'; - if (! empty($conf->mailing->enabled)) - { - $langs->load("mails"); - print '<td class="nowrap">'.$langs->trans("NbOfEMailingsReceived").'</td>'; - print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/list.php?filteremail='.urlencode($object->email).'">'.$object->getNbOfEMailings().'</a></td>'; - } - else - { - print '<td colspan="2"> </td>'; - } - print '</tr>'; - - // Instant message and no email - print '<tr><td>'.$langs->trans("IM").'</td><td>'.$object->jabberid.'</td>'; - if (!empty($conf->mailing->enabled)) - { - print '<td>'.$langs->trans("No_Email").'</td><td>'.yn($object->no_email).'</td>'; - } - else - { - print '<td colspan="2"> </td>'; - } - print '</tr>'; - - print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">'; - print $object->LibPubPriv($object->priv); - print '</td></tr>'; - - // Note Public - print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td><td colspan="3">'; - print nl2br($object->note_public); - print '</td></tr>'; - - // Note Private - print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">'; - print nl2br($object->note_private); - print '</td></tr>'; - - // Other attributes - $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } - - print '</table>'; - - dol_fiche_end(); - - 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' '; - 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)); - } -} - - -/** - * Function to output a form to add object into a category - * - * @param DoliDb $db Database handler - * @param Object $object Object we want to see categories it can be classified into - * @param int $typeid Type of category (0, 1, 2, 3) - * @param int $socid Id thirdparty - * @param int $showclassifyform 1=Add form to 'Classify', 0=Do not show form to 'Classify' - * @return int 0 - */ -function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1) -{ - global $user,$langs,$form,$bc; - - $title='NotDefined'; - if ($typeid == Categorie::TYPE_PRODUCT) $title = $langs->trans("ProductsCategoriesShort"); - if ($typeid == Categorie::TYPE_SUPPLIER) $title = $langs->trans("SuppliersCategoriesShort"); - 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) - { - $linktocreate='<a href="'.DOL_URL_ROOT.'/categories/card.php?action=create&origin='.$object->id.'&type='.$typeid.'&urlfrom='.urlencode($_SERVER["PHP_SELF"].'?'.(($typeid==Categorie::TYPE_SUPPLIER||$typeid==Categorie::TYPE_CUSTOMER)?'socid':'id').'='.$object->id.'&type='.$typeid).'">'; - $linktocreate.=$langs->trans("CreateCat").' '; - $linktocreate.=img_picto($langs->trans("Create"),'filenew'); - $linktocreate.="</a>"; - } - - print '<br>'; - print load_fiche_titre($title,$linktocreate,''); - - // Form to add record into a category - if ($showclassifyform) - { - print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; - print '<input type="hidden" name="typeid" value="'.$typeid.'">'; - print '<input type="hidden" name="type" value="'.$typeid.'">'; - print '<input type="hidden" name="id" value="'.$object->id.'">'; - print '<table class="noborder" width="100%">'; - print '<tr class="liste_titre"><td width="40%">'; - print '<span class="hideonsmartphone">'.$langs->trans("ClassifyInCategory").' </span>'; - print $form->select_all_categories($typeid,'auto'); - print '</td>'; - print '<td><input type="submit" class="button" value="'.$langs->trans("Classify").'"></td>'; - print '</tr>'; - print '</table>'; - print '</form>'; - print '<br>'; - } - - - $c = new Categorie($db); - $cats = $c->containing($object->id,$typeid); - - if (count($cats) > 0) - { - if ($typeid == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductIsInCategories"); - if ($typeid == Categorie::TYPE_SUPPLIER) $title=$langs->trans("CompanyIsInSuppliersCategories"); - 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>'; - - $var = true; - foreach ($cats as $cat) - { - $ways = $cat->print_all_ways(); - - foreach ($ways as $way) - { - $var = ! $var; - print "<tr ".$bc[$var].">"; - - // Categorie - print "<td>".img_object('','category').' '.$way."</td>"; - - // Link to delete from category - print '<td align="right">'; - $permission=0; - if ($typeid == Categorie::TYPE_PRODUCT) $permission=($user->rights->produit->creer || $user->rights->service->creer); - 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_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."&type=".$typeid."&removecat=".$cat->id."'>"; - print img_delete($langs->trans("DeleteFromCat")).' '; - print $langs->trans("DeleteFromCat")."</a>"; - } - else - { - print ' '; - } - print "</td>"; - - print "</tr>\n"; - } - } - print "</table>\n"; - } - else if ($cats < 0) - { - print $langs->trans("ErrorUnknown"); - } - else - { - if ($typeid == Categorie::TYPE_PRODUCT) $title=$langs->trans("ProductHasNoCategory"); - if ($typeid == Categorie::TYPE_SUPPLIER) $title=$langs->trans("CompanyHasNoCategory"); - 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/>"; - } - return 0; -} - -llxFooter(); - -$db->close(); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 0f427381d15209ce6635e292e55c1e301911a394..7a459c17cb9bf8d8270dc10e58a360193dbbf976 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -113,17 +113,6 @@ function societe_prepare_head(Societe $object) $head[$h][2] = 'project'; $h++; } - //show categorie tab - /*if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $type = Categorie::TYPE_CUSTOMER; - if ($object->fournisseur) $type = Categorie::TYPE_SUPPLIER; - $head[$h][0] = DOL_URL_ROOT.'/categories/categorie.php?socid='.$object->id."&type=".$type; - $head[$h][1] = $langs->trans('Categories'); - $head[$h][2] = 'category'; - $h++; - }*/ // Tab to link resources if (! empty($conf->resource->enabled) && ! empty($conf->global->RESOURCE_ON_THIRDPARTIES)) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6252811fff25acf0852bcb45343354e12b266fb8..cf825a50e2824559b786a84d4e043c5bb19da672 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3175,7 +3175,7 @@ class Product extends CommonObject if ($reshook > 0) $linkclose = $hookmanager->resPrint; - if ($option == 'supplier') { + if ($option == 'supplier' || $option == 'category') { $link = '<a href="'.DOL_URL_ROOT.'/product/fournisseurs.php?id='.$this->id.$linkclose; $linkend='</a>'; } else if ($option == 'stock') { @@ -3184,8 +3184,6 @@ class Product extends CommonObject } else if ($option == 'composition') { $link = '<a href="'.DOL_URL_ROOT.'/product/composition/card.php?id='.$this->id.$linkclose; $linkend='</a>'; - } else if ($option == 'category') { - $link = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type=0'.$linkclose; } else { $link = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$this->id.$linkclose; $linkend='</a>'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3bd03e0673e6dcd7ed9729dcbe16959e462c469e..d318e132f92ebbd19fcecf1f4254bbf5cb594a67 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1855,7 +1855,7 @@ class Societe extends CommonObject $label.= '<div width="100%">'; - if ($option == 'customer' || $option == 'compta') + if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') { $label.= '<u>' . $langs->trans("ShowCustomer") . '</u>'; $link = '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$this->id; @@ -1880,16 +1880,6 @@ class Societe extends CommonObject $label.= '<u>' . $langs->trans("ShowProject") . '</u>'; $link = '<a href="'.DOL_URL_ROOT.'/societe/project.php?socid='.$this->id; } - else if ($option == 'category') - { - $label.= '<u>' . $langs->trans("ShowCategory") . '</u>'; - $link = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type=2'; - } - else if ($option == 'category_supplier') - { - $label.= '<u>' . $langs->trans("ShowCategorySupplier") . '</u>'; - $link = '<a href="'.DOL_URL_ROOT.'/categories/categorie.php?id='.$this->id.'&type=1'; - } else if ($option == 'margin') { $label.= '<u>' . $langs->trans("ShowMargin") . '</u>';