From 2ba795fcbc94740133b1a926a56b29964eac58c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 27 Feb 2015 15:08:08 +0100 Subject: [PATCH 1/2] NEW: [ task #851 ] Add a new field: Commercial name --- htdocs/categories/categorie.php | 6 ++++ htdocs/comm/card.php | 6 ++++ htdocs/comm/list.php | 12 ++++++-- htdocs/comm/prospect/list.php | 12 ++++++-- .../core/class/commondocgenerator.class.php | 2 ++ htdocs/core/lib/pdf.lib.php | 28 +++++++++++++++++++ .../commande/doc/pdf_einstein.modules.php | 20 ++++++------- .../commande/doc/pdf_proforma.modules.php | 20 ++++++------- .../contract/doc/pdf_strato.modules.php | 18 ++++++------ .../expedition/doc/pdf_merou.modules.php | 22 +++++++-------- .../expedition/doc/pdf_rouget.modules.php | 21 ++++++-------- .../modules/facture/doc/pdf_crabe.modules.php | 20 ++++++------- .../fichinter/doc/pdf_soleil.modules.php | 20 ++++++------- .../livraison/doc/pdf_typhon.modules.php | 20 ++++++------- .../modules/propale/doc/pdf_azur.modules.php | 22 +++++++-------- .../pdf/pdf_canelle.modules.php | 20 ++++++------- .../pdf/pdf_muscadet.modules.php | 20 ++++++------- htdocs/fourn/card.php | 6 ++++ htdocs/fourn/list.php | 11 ++++++-- .../install/mysql/migration/3.7.0-3.8.0.sql | 3 +- htdocs/install/mysql/tables/llx_societe.sql | 2 ++ htdocs/societe/agenda.php | 6 ++++ htdocs/societe/class/societe.class.php | 22 ++++++++++++--- htdocs/societe/consumption.php | 5 ++++ htdocs/societe/document.php | 6 ++++ htdocs/societe/note.php | 6 ++++ htdocs/societe/notify/card.php | 6 ++++ htdocs/societe/price.php | 6 ++++ htdocs/societe/soc.php | 27 ++++++++++++------ htdocs/societe/societe.php | 28 ++++++++++--------- htdocs/societe/societecontact.php | 6 ++++ 31 files changed, 274 insertions(+), 155 deletions(-) diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 0746475ecec..a5aafd9986e 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -6,6 +6,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Marcos García * * 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 @@ -248,6 +249,11 @@ if ($socid) print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom','','&type='.$type); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $soc->commercial_name; + print ""; + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans('Prefix').''.$soc->prefix_comm.''; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index ffc01a998d5..1f98dafc81e 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -7,6 +7,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Alexandre Spangaro + * Copyright (C) 2015 Marcos García * * 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 @@ -219,6 +220,11 @@ if ($id > 0) print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $object->commercial_name; + print ""; + // Prospect/Customer print ''.$langs->trans('ProspectCustomer').''; print $object->getLibCustProspStatut(); diff --git a/htdocs/comm/list.php b/htdocs/comm/list.php index 06b26d88f48..4960d610e2c 100644 --- a/htdocs/comm/list.php +++ b/htdocs/comm/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Marcos García * * 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 @@ -101,7 +102,7 @@ $thirdpartystatic=new Societe($db); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); -$sql = "SELECT s.rowid, s.nom as name, s.client, s.zip, s.town, st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta, s.status as status,"; +$sql = "SELECT s.rowid, s.nom as name, s.commercial_name, s.client, s.zip, s.town, st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta, s.status as status,"; $sql.= " s.datec, s.canvas"; if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -119,7 +120,13 @@ if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_company) { - $sql .= natural_search('s.nom', $search_company); + $sql .= natural_search( + array( + 's.nom', + 's.commercial_name' + ), + $search_company + ); } if ($search_zipcode) $sql.= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'"; if ($search_town) { @@ -255,6 +262,7 @@ if ($result) $thirdpartystatic->code_client=$obj->code_client; $thirdpartystatic->canvas=$obj->canvas; $thirdpartystatic->status=$obj->status; + $thirdpartystatic->commercial_name=$obj->commercial_name; print $thirdpartystatic->getNomUrl(1); print ''; print ''.$obj->zip.''; diff --git a/htdocs/comm/prospect/list.php b/htdocs/comm/prospect/list.php index 999c212a80d..533bec8728d 100644 --- a/htdocs/comm/prospect/list.php +++ b/htdocs/comm/prospect/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015 Marcos García * * 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 @@ -194,7 +195,7 @@ if (empty($reshook)) { $formother=new FormOther($db); $form=new Form($db); -$sql = "SELECT s.rowid, s.nom as name, s.zip, s.town, s.datec, s.status as status, s.code_client, s.client,"; +$sql = "SELECT s.rowid, s.nom as name, s.commercial_name, s.zip, s.town, s.datec, s.status as status, s.code_client, s.client,"; $sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,"; $sql.= " d.nom as departement"; if ((!$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) @@ -214,7 +215,13 @@ if ($catid == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ; if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_nom) { - $sql .= natural_search('s.nom', $search_nom); + $sql .= natural_search( + array( + 's.nom', + 's.commercial_name' + ), + $search_nom + ); } if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape(strtolower($search_zipcode))."%'"; if ($search_town) { @@ -423,6 +430,7 @@ if ($resql) $prospectstatic->code_client=$obj->code_client; $prospectstatic->client=$obj->client; $prospectstatic->fk_prospectlevel=$obj->fk_prospectlevel; + $prospectstatic->commercial_name=$obj->commercial_name; print $prospectstatic->getNomUrl(1,'prospect'); print ''; print "".$obj->zip." "; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index b7f8e09677f..8c3ed3cc09c 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Marcos García * * 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 @@ -147,6 +148,7 @@ abstract class CommonDocGenerator $array_thirdparty = array( 'company_name'=>$object->name, + 'company_commercial_name' => $object->commercial_name, 'company_email'=>$object->email, 'company_phone'=>$object->phone, 'company_fax'=>$object->fax, diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1c5ae62d014..a753888e8ae 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -9,6 +9,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2014 Cedric GROSS * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> + * Copyright (C) 2015 Marcos García * * 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 @@ -286,6 +287,33 @@ function pdf_getHeightForLogo($logo, $url = false) return $height; } +/** + * Returns the name of the thirdparty + * + * @param Societe|Contact $thirdparty + * @param Translate $outputlangs + * @return string + */ +function pdfBuildThirdpartyName($thirdparty, Translate $outputlangs) +{ + //Recipient name + $socname = ''; + + // On peut utiliser le nom de la societe du contact + if ($thirdparty instanceof Societe) { + if (!empty($thirdparty->commercial_name)) { + $socname = $thirdparty->commercial_name."\n"; + } + + $socname .= $thirdparty->name; + } elseif ($thirdparty instanceof Contact) { + $socname = $thirdparty->socname; + } else { + throw new InvalidArgumentException(); + } + + return $outputlangs->convToOutputCharset($socname); +} /** * Return a string with full address formated diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index f6d28a4f135..c4c6124c0c5 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -4,6 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2015 Marcos García * * 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 @@ -1224,19 +1225,16 @@ class pdf_einstein extends ModelePDFCommandes $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); // Show recipient diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 2b8aaa21818..5afc0fe5c46 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -4,6 +4,7 @@ * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2015 Marcos García * * 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 @@ -1185,19 +1186,16 @@ class pdf_proforma extends ModelePDFCommandes $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); // Show recipient diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 46364b23d0d..ff7ce036c5d 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -5,6 +5,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011 Fabrice CHERRIER * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2015 Marcos García * * 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 @@ -588,17 +589,16 @@ class pdf_strato extends ModelePDFContract $this->recipient = $object->client; - // Recipient name - if (! empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $this->recipient->name = $outputlangs->convToOutputCharset($socname); - } - else { - $this->recipient->name = $outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target'); // Show recipient diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 312e8bc5e1f..f26d85615e5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -2,7 +2,8 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Marcos García * * 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 @@ -622,19 +623,16 @@ class pdf_merou extends ModelePdfExpedition $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails'); $blDestX=$blExpX+55; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 9c5dada3a72..f7922c5eda5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2014 Marcos García + * Copyright (C) 2014-2015 Marcos García * * 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 @@ -639,19 +639,16 @@ class pdf_rouget extends ModelePdfExpedition $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,(!empty($object->contact)?$object->contact:null),$usecontact,'targetwithdetails'); // Show recipient diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 4c340a12cfa..c18e782e255 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -6,6 +6,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2015 Marcos García * * 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 @@ -1514,19 +1515,16 @@ class pdf_crabe extends ModelePDFFactures $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); // Show recipient diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 1a26a161511..c97fdb15807 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -5,6 +5,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011 Fabrice CHERRIER * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015 Marcos García * * 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 @@ -609,19 +610,16 @@ class pdf_soleil extends ModelePDFFicheinter $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target'); // Show recipient diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index e3e9be99411..c56631d780b 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -4,6 +4,7 @@ * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2008 Chiptronik * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2015 Marcos García * 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 @@ -820,19 +821,16 @@ class pdf_typhon extends ModelePDFDeliveryOrder $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); // Show recipient diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 35953b8521f..93e3533cc7b 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -3,7 +3,8 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2015 Marcos García * * 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 @@ -1323,19 +1324,16 @@ class pdf_azur extends ModelePDFPropales $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); // Show recipient diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index d100a45b828..5c03f3de20e 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -1,6 +1,7 @@ * Copyright (C) 2010-2014 Laurent Destailleur + * Copyright (C) 2015 Marcos García * * 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 @@ -1022,19 +1023,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $mysoc->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($mysoc->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $mysoc; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target'); // Show recipient diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 8d59e77cb12..ab9dc06aea7 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2015 Marcos García * * 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 @@ -1071,19 +1072,16 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $result=$object->fetch_contact($arrayidcontact[0]); } - // Recipient name - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname; - else $socname = $object->client->name; - $carac_client_name=$outputlangs->convToOutputCharset($socname); - } - else - { - $carac_client_name=$outputlangs->convToOutputCharset($object->client->name); + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $thirdparty = $object->contact; + } else { + $thirdparty = $object->client; } + $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target'); // Show recipient diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 3f0636e324a..ebbf880e15d 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2014 Jean Heimburger + * Copyright (C) 2015 Marcos García * * 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 @@ -132,6 +133,11 @@ if ($object->id > 0) print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $object->commercial_name; + print ""; + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php index b0d7caf8695..8a3da37ec6e 100644 --- a/htdocs/fourn/list.php +++ b/htdocs/fourn/list.php @@ -92,7 +92,7 @@ $thirdpartystatic=new Societe($db); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); -$sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.datec, st.libelle as stcomm, s.prefix_comm, s.status as status, "; +$sql = "SELECT s.rowid as socid, s.nom as name, s.commercial_name, s.zip, s.town, s.datec, st.libelle as stcomm, s.prefix_comm, s.status as status, "; $sql.= "code_fournisseur, code_compta_fournisseur"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -109,7 +109,13 @@ if ($socname) { $sortorder = "ASC"; } if ($search_name) { - $sql .= natural_search('s.nom', $search_name); + $sql .= natural_search( + array( + 's.nom', + 's.commercial_name' + ), + $search_name + ); } if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'"; if ($search_town) { @@ -216,6 +222,7 @@ if ($resql) $thirdpartystatic->id=$obj->socid; $thirdpartystatic->name=$obj->name; $thirdpartystatic->status=$obj->status; + $thirdpartystatic->commercial_name=$obj->commercial_name; print ""; print ''; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index c09c434d27e..1c897604559 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -195,7 +195,8 @@ CREATE TABLE llx_expensereport_det ALTER TABLE llx_projet ADD COLUMN budget_amount double(24,8); - +-- Commercial name +ALTER TABLE llx_societe ADD COLUMN commercial_name varchar(128) NULL; create table llx_commande_fournisseurdet_extrafields diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index e28cf062224..801df8439b5 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -4,6 +4,7 @@ -- Copyright (C) 2005-2010 Regis Houssin -- Copyright (C) 2010 Juanjo Menent -- Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> +-- Copyright (C) 2015 Marcos García -- -- 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 @@ -24,6 +25,7 @@ create table llx_societe ( rowid integer AUTO_INCREMENT PRIMARY KEY, nom varchar(128), -- company reference name (should be same length than adherent.societe) + commercial_name varchar(128) NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id ref_ext varchar(128), -- reference into an external system (not used by dolibarr) diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 19d943798ce..027c1648aaa 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -5,6 +5,7 @@ * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2015 Marcos García * * 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 @@ -82,6 +83,11 @@ if ($socid) print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $object->commercial_name; + print ""; + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 77673b82ed3..a653e81ad6a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2013 Peter Fontaine - * Copyright (C) 2014 Marcos García + * Copyright (C) 2014-2015 Marcos García * * 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 @@ -61,6 +61,13 @@ class Societe extends CommonObject var $firstname; var $lastname; + + /** + * Commercial name + * @var string + */ + public $commercial_name; + var $particulier; var $civility_id; var $address; @@ -424,8 +431,8 @@ class Societe extends CommonObject if ($result >= 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, import_key)"; - $sql.= " VALUES ('".$this->db->escape($this->name)."', ".$conf->entity.", '".$this->db->idate($now)."'"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, commercial_name, entity, datec, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm, import_key)"; + $sql.= " VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->commercial_name)."', ".$conf->entity.", '".$this->db->idate($now)."'"; $sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null"); $sql.= ", ".(! empty($this->canvas) ? "'".$this->canvas."'":"null"); $sql.= ", ".$this->status; @@ -637,6 +644,7 @@ class Societe extends CommonObject $this->id = $id; $this->name = $this->name?trim($this->name):trim($this->nom); $this->nom = $this->name; // For backward compatibility + $this->commercial_name = trim($this->commercial_name); $this->ref_ext = trim($this->ref_ext); $this->address = $this->address?trim($this->address):trim($this->address); $this->zip = $this->zip?trim($this->zip):trim($this->zip); @@ -744,6 +752,7 @@ class Societe extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required + $sql .= ",commercial_name = '" . $this->db->escape($this->commercial_name) ."'"; $sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null"); $sql .= ",address = '" . $this->db->escape($this->address) ."'"; @@ -962,7 +971,7 @@ class Societe extends CommonObject if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT s.rowid, s.nom as name, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; + $sql = 'SELECT s.rowid, s.nom as name, s.commercial_name, s.entity, s.ref_ext, s.ref_int, s.address, s.datec as date_creation, s.prefix_comm'; $sql .= ', s.status'; $sql .= ', s.price_level'; $sql .= ', s.tms as date_modification'; @@ -1021,6 +1030,7 @@ class Societe extends CommonObject $this->ref = $obj->rowid; $this->name = $obj->name; $this->nom = $obj->name; // deprecated + $this->commercial_name = $obj->commercial_name; $this->ref_ext = $obj->ref_ext; $this->ref_int = $obj->ref_int; @@ -1721,6 +1731,10 @@ class Societe extends CommonObject $name =$code.' '.$name; } + if (!empty($this->commercial_name)) { + $name .= ' ('.$this->commercial_name.')'; + } + $result=''; $label=''; $lien=''; $lienfin=''; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index d8aad10d054..74f9dd8cc0a 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -2,6 +2,7 @@ /* Copyright (C) 2012-2013 Philippe Berthet * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2015 Marcos García * * Version V1.1 Initial version of Philippe Berthet * Version V2 Change to be compatible with 3.4 and enhanced to be more generic @@ -116,6 +117,10 @@ print ''; print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print ''; +// Commercial name +print ''; +print ''; + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index c2ad751f196..f77e353b06e 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015 Marcos García * * 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 @@ -115,6 +116,11 @@ if ($object->id) print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $object->commercial_name; + print ""; + // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index d00e92887d1..47ceee41854 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Marcos García * * 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 @@ -81,6 +82,11 @@ if ($id > 0) print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $object->commercial_name; + print ""; + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 1845669dcfc..ed594db19c2 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2015 Marcos García * * 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 @@ -143,6 +144,11 @@ if ($result > 0) print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print ''; + // Commercial name + print ''.$langs->trans('CommercialName').''; + print $object->commercial_name; + print ""; + // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 0932144a860..27ece9a8d14 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2015 Marcos García * * 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 @@ -136,6 +137,11 @@ print '' . $langs->trans("ThirdPartyName") . 'showrefnav($soc, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); print ''; +// Commercial name +print ''.$langs->trans('CommercialName').''; +print $soc->commercial_name; +print ""; + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print '' . $langs->trans('Prefix') . '' . $soc->prefix_comm . ''; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 23d9aa2d8e1..0c53744270b 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -7,6 +7,7 @@ * Copyright (C) 2008 Patrick Raguin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2013 Alexandre Spangaro + * Copyright (C) 2015 Marcos García * * 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 @@ -143,7 +144,9 @@ if (empty($reshook)) else { $object->name = GETPOST('name', 'alpha')?GETPOST('name', 'alpha'):GETPOST('nom', 'alpha'); + $object->commercial_name = GETPOST('commercial_name'); } + $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); @@ -764,6 +767,7 @@ else $("#radiocompany").click(function() { $(".individualline").hide(); $("#typent_id").val(0); + $("#commercial_name").show(); $("#effectif_id").val(0); $("#TypeName").html(document.formsoc.ThirdPartyName.value); document.formsoc.private.value=0; @@ -771,6 +775,7 @@ else $("#radioprivate").click(function() { $(".individualline").show(); $("#typent_id").val(id_te_private); + $("#commercial_name").hide(); $("#effectif_id").val(id_ef15); $("#TypeName").html(document.formsoc.LastName.value); document.formsoc.private.value=1; @@ -902,6 +907,10 @@ else print ''; } + // Commercial name + print ''; + print ''; + // Address print ''; print '