From 8adac462fab34b152532fdb1c173e4ed6135fb91 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 12 Jan 2012 18:50:10 +0800 Subject: [PATCH] Fix: share customer code with a referent entity --- .../societe/mod_codeclient_elephant.php | 12 ++++++---- .../modules/societe/mod_codeclient_monkey.php | 7 ++++-- htdocs/societe/admin/societe.php | 23 +++++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 159365d62f2..3dd78144dae 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2009 Laurent Destailleur - * Copyright (C) 2007 Regis Houssin + * Copyright (C) 2007-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -68,11 +68,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode */ function info($langs) { - global $conf; + global $conf, $mc; $langs->load("companies"); $form = new Form($this->db); + + $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled="disabled"' : ''); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= '
'; @@ -90,15 +92,15 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode // Parametrage du prefix customers $texte.= ''.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'; - $texte.= ''.$form->textwithpicto('',$tooltip,1,1).''; + $texte.= ''.$form->textwithpicto('',$tooltip,1,1).''; - $texte.= '  '; + $texte.= '  '; $texte.= ''; // Parametrage du prefix suppliers $texte.= ''.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'; - $texte.= ''.$form->textwithpicto('',$tooltip,1,1).''; + $texte.= ''.$form->textwithpicto('',$tooltip,1,1).''; $texte.= ''; $texte.= ''; diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 89dc0653244..f2e59ee7e0c 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -91,7 +91,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode */ function getNextValue($objsoc=0,$type=-1) { - global $db, $conf; + global $db, $conf, $mc; $return='000001'; @@ -117,7 +117,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode $sql = "SELECT MAX(SUBSTRING(".$field." FROM ".$posindice.")) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".getEntity('societe'); $resql=$db->query($sql); if ($resql) @@ -212,8 +212,11 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode */ function verif_dispo($db, $code, $soc) { + global $conf, $mc; + $sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe"; $sql.= " WHERE code_client = '".$code."'"; + $sql.= " AND entity = ".getEntity('societe'); if ($soc->id > 0) $sql.= " AND rowid != ".$soc->id; dol_syslog(get_class($this)."::verif_dispo sql=".$sql, LOG_DEBUG); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index d00749093d5..84fb0910df6 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -222,8 +222,8 @@ dol_htmloutput_mesg($mesg); print_titre($langs->trans("CompanyCodeChecker")); -print "\n"; -print "\n"; +print '
'."\n"; +print ''."\n"; print ' '; print ' '; print ' '; @@ -260,22 +260,25 @@ foreach ($conf->file->dol_document_root as $dirroot) if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; $var = !$var; - print "\n \n \n"; - print '\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") { - print "\n"; } else { - print ''; + if (! $disabled) print ''; + print ''; } print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").'
".$modCodeTiers->nom.""; - print $modCodeTiers->info($langs); - print "'.$modCodeTiers->getExample($langs)."
'.$modCodeTiers->nom.''.$modCodeTiers->info($langs).''.$modCodeTiers->getExample($langs).'\n"; + print ''."\n"; print img_picto($langs->trans("Activated"),'switch_on'); print "'; + $disabled = ((is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); + print ''; + if (! $disabled) print ''; print img_picto($langs->trans("Disabled"),'switch_off'); - print '';