On rend bouton selection contact inactif si aucun contact dfini.

This commit is contained in:
Laurent Destailleur 2007-11-04 18:34:16 +00:00
parent 5371e6bb5b
commit fa5d822e76
10 changed files with 83 additions and 68 deletions

View File

@ -272,12 +272,15 @@ if ($id > 0)
print '<td colspan="1">';
// On récupère les id des contacts déjà sélectionnés
//$contactAlreadySelected = $propal->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
$nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$propal->selectTypeContact($propal, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"';
print '></td>';
print '</tr>';
print "</form>";

View File

@ -274,12 +274,15 @@ if ($id > 0)
print '<td colspan="1">';
// On récupère les id des contacts déjà sélectionnés
// $contactAlreadySelected = $commande->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
$nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$commande->selectTypeContact($commande, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"';
print '></td>';
print '</tr>';
print "</form>";

View File

@ -786,8 +786,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
print '<tr><td>'.$langs->trans('Customer').'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
/*
* Contact de la commande
*/
* Contact de la commande
*/
print "<tr><td>".$langs->trans("DefaultContact").'</td><td>';
$html->select_contacts($soc->id,$setcontact,'contactidp',1);
print '</td></tr>';

View File

@ -17,7 +17,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
@ -254,12 +253,15 @@ if ($id > 0)
print '<td colspan="1">';
// On récupère les id des contacts déjà sélectionnés
//$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
$nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$facture->selectTypeContact($facture, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"';
print '></td>';
print '</tr>';
print "</form>";

View File

@ -275,12 +275,15 @@ if ($id > 0)
print '<td colspan="1">';
// On récupère les id des contacts déjà sélectionnés
//$contactAlreadySelected = $contrat->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
$nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$contrat->selectTypeContact($contrat, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"';
print '></td>';
print '</tr>';
print "</form>";

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
/* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -259,12 +260,15 @@ if ($id > 0)
print '<td colspan="1">';
// On récupère les id des contacts déjà sélectionnés
//$contactAlreadySelected = $fichinter->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
$nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>';
print '<td>';
$fichinter->selectTypeContact($fichinter, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"';
print '></td>';
print '</tr>';
print "</form>";

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**

View File

@ -792,65 +792,65 @@ class Form
* \param htmlname Nom champ formulaire ('none' pour champ non editable)
* \param show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* \param exclude Liste des id contacts à exclure
* \return int <0 si ko, >=0 si ok
* \return int <0 if KO, Nb of contact in list if OK
*/
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='')
{
// Permettre l'exclusion de contacts
if (is_array($exclude))
{
$excludeContacts = implode("','",$exclude);
}
// On recherche les societes
$sql = "SELECT s.rowid, s.name, s.firstname FROM";
$sql.= " ".MAIN_DB_PREFIX ."socpeople as s";
$sql.= " WHERE fk_soc=".$socid;
if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')";
$sql.= " ORDER BY s.name ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows();
if ($num==0) return 0;
if ($htmlname != 'none') print '<select class="flat" name="'.$htmlname.'">';
if ($showempty) print '<option value="1">&nbsp;</option>';
$num = $this->db->num_rows();
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object();
if ($htmlname != 'none')
{
if ($selected && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->name.' '.$obj->firstname.'</option>';
}
else
{
print '<option value="'.$obj->rowid.'">'.$obj->name.' '.$obj->firstname.'</option>';
}
}
{
// Permettre l'exclusion de contacts
if (is_array($exclude))
{
$excludeContacts = implode("','",$exclude);
}
// On recherche les societes
$sql = "SELECT s.rowid, s.name, s.firstname FROM";
$sql.= " ".MAIN_DB_PREFIX ."socpeople as s";
$sql.= " WHERE fk_soc=".$socid;
if (is_array($exclude) && $excludeContacts) $sql.= " AND s.rowid NOT IN ('".$excludeContacts."')";
$sql.= " ORDER BY s.name ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
if ($num == 0) return 0;
if ($htmlname != 'none') print '<select class="flat" name="'.$htmlname.'">';
if ($showempty) print '<option value="1">&nbsp;</option>';
$num = $this->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($htmlname != 'none')
{
if ($selected && $selected == $obj->rowid)
{
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->name.' '.$obj->firstname.'</option>';
}
else
{
if ($selected == $obj->rowid) print $obj->name.' '.$obj->firstname;
print '<option value="'.$obj->rowid.'">'.$obj->name.' '.$obj->firstname.'</option>';
}
$i++;
}
else
{
if ($selected == $obj->rowid) print $obj->name.' '.$obj->firstname;
}
$i++;
}
if ($htmlname != 'none') print '</select>';
return 1;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
if ($htmlname != 'none') print '</select>';
return $num;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
/**

View File

@ -125,6 +125,7 @@ Supplier=Supplier
CompanyList=Companies' list
AddContact=Add contact
Contact=Contact
NoContactDefined=No contact defined for this third party
DefaultContact=Default contact
AddCompany=Add company
AddThirdParty=Add third party

View File

@ -125,6 +125,7 @@ Supplier=Fournisseur
CompanyList=Liste des sociétés
AddContact=Créer contact
Contact=Contact
NoContactDefined=Aucun contact défini pour ce tiers
DefaultContact=Contact par défaut
AddCompany=Créer société
AddThirdParty=Créer tiers