Fix: share customer code with a referent entity

This commit is contained in:
Regis Houssin 2012-01-12 18:50:10 +08:00
parent 39a522c1a1
commit 8adac462fa
3 changed files with 25 additions and 17 deletions

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -90,15 +92,15 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
// Parametrage du prefix customers
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
$texte.= '</tr>';
// Parametrage du prefix suppliers
$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
$texte.= '</tr>';
$texte.= '</table>';

View File

@ -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);

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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 "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre">'."\n";
print ' <td>'.$langs->trans("Name").'</td>';
print ' <td>'.$langs->trans("Description").'</td>';
print ' <td>'.$langs->trans("Example").'</td>';
@ -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 "<tr ".$bc[$var].">\n <td width=\"140\">".$modCodeTiers->nom."</td>\n <td>";
print $modCodeTiers->info($langs);
print "</td>\n";
print '<td nowrap="nowrap">'.$modCodeTiers->getExample($langs)."</td>\n";
print '<tr '.$bc[$var].'>'."\n";
print '<td width="140">'.$modCodeTiers->nom.'</td>'."\n";
print '<td>'.$modCodeTiers->info($langs).'</td>'."\n";
print '<td nowrap="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n";
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
{
print "<td align=\"center\">\n";
print '<td align="center">'."\n";
print img_picto($langs->trans("Activated"),'switch_on');
print "</td>\n";
}
else
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&amp;value='.$file.'">';
$disabled = ((is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true);
print '<td align="center">';
if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&amp;value='.$file.'">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a></td>';
if (! $disabled) print '</a>';
print '</td>';
}
print '<td align="center">';