New: Gestion gnrique des contacts sur les contrats.

This commit is contained in:
Laurent Destailleur 2005-09-17 17:38:02 +00:00
parent 3f3c66ef72
commit c8af875880
7 changed files with 88 additions and 51 deletions

View File

@ -89,7 +89,7 @@ $tabsql[7] = "SELECT a.id as rowid, a.id as code, a.libelle AS libelle, a.ded
$tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
$tabsql[9] = "SELECT code as rowid, code, code_iso, label as libelle, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[10]= "SELECT t.rowid, t.taux, p.libelle as pays, t.recuperableonly, t.note, t.active FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
$tabsql[11]= "SELECT t.rowid as rowid, code, element, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
// Tri par defaut
$tabsqlsort[1] ="pays, code ASC";
@ -102,7 +102,7 @@ $tabsqlsort[7] ="a.libelle ASC";
$tabsqlsort[8] ="libelle ASC";
$tabsqlsort[9] ="code ASC";
$tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC";
$tabsqlsort[11]="element ASC, code ASC, libelle ASC";
$tabsqlsort[11]="element ASC, source ASC, code ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield[1] = "code,libelle,pays";
@ -115,7 +115,7 @@ $tabfield[7] = "libelle,deductible";
$tabfield[8] = "code,libelle";
$tabfield[9] = "code,code_iso,libelle";
$tabfield[10]= "pays,taux,recuperableonly,note";
$tabfield[11]= "element,code,libelle";
$tabfield[11]= "element,source,code,libelle";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert[1] = "code,libelle,fk_pays";
@ -128,7 +128,7 @@ $tabfieldinsert[7] = "libelle,deductible";
$tabfieldinsert[8] = "code,libelle";
$tabfieldinsert[9] = "code,code_iso,libelle";
$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,note";
$tabfieldinsert[11]= "element,code,libelle";
$tabfieldinsert[11]= "element,source,code,libelle";
// Nom du rowid si le champ n'est pas de type autoincrément
$tabrowid[1] = "";
@ -210,7 +210,7 @@ if ($_POST["actionadd"])
$result = $db->query($sql);
if (!$result)
{
if ($db->errno() == DB_ERROR_RECORD_ALREADY_EXISTS) {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
$msg=$langs->trans("ErrorRecordAlreadyExists").'<br>';
}
else {
@ -334,6 +334,7 @@ if ($_GET["id"])
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de données
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
if ($fieldlist[$field]=='source') $valuetoshow=$langs->trans("Contact");
if ($fieldlist[$field]=='lang') $valuetoshow=$langs->trans("Language");
if ($fieldlist[$field]=='type') $valuetoshow=$langs->trans("Type");
if ($fieldlist[$field]=='code') $valuetoshow=$langs->trans("Code");
@ -369,19 +370,31 @@ if ($_GET["id"])
$html->select_lang(MAIN_LANG_DEFAULT,'lang');
print '</td>';
}
// le type de l'element (pour les type de contact).'
elseif ($fieldlist[$field] == 'element') {
// Le type de l'element (pour les type de contact).'
elseif ($fieldlist[$field] == 'element')
{
$langs->load("orders");
$langs->load("contracts");
$langs->load("project");
$langs->load("propal");
$langs->load("bills");
print '<td>';
$elementList = array();
// un peu crad mais je n'ai pas de meilleure idee.
$elementList["contrat"] = "contrat";
$elementList["projet"] = "projet";
$elementList["propal"] = "propal";
$elementList["facture"] = "facture";
$elementList = array("commande"=>$langs->trans("Order"),
"contrat"=>$langs->trans("Contract"),
"projet"=>$langs->trans("Project"),
"propal"=>$langs->trans("Propal"),
"facture"=>$langs->trans("Bill"));
$html->select_array('element', $elementList);
print '</td>';
}
// La source de l'element (pour les type de contact).'
elseif ($fieldlist[$field] == 'source') {
print '<td>';
$elementList = array("internal"=>$langs->trans("Internal"),
"external"=>$langs->trans("External"));
$html->select_array('source', $elementList);
print '</td>';
}
elseif ($fieldlist[$field] == 'type') {
print '<td>';
print 'user<input type="hidden" name="type" value="user">';
@ -422,11 +435,12 @@ if ($_GET["id"])
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de données
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
if ($fieldlist[$field]=='lang') $valuetoshow=$langs->trans("Language");
if ($fieldlist[$field]=='type') $valuetoshow=$langs->trans("Type");
if ($fieldlist[$field]=='code') $valuetoshow=$langs->trans("Code");
if ($fieldlist[$field]=='libelle') $valuetoshow=$langs->trans("Label")."*";
if ($fieldlist[$field]=='pays') $valuetoshow=$langs->trans("Country");
if ($fieldlist[$field]=='source') $valuetoshow=$langs->trans("Contact");
if ($fieldlist[$field]=='lang') $valuetoshow=$langs->trans("Language");
if ($fieldlist[$field]=='type') $valuetoshow=$langs->trans("Type");
if ($fieldlist[$field]=='code') $valuetoshow=$langs->trans("Code");
if ($fieldlist[$field]=='libelle') $valuetoshow=$langs->trans("Label")."*";
if ($fieldlist[$field]=='pays') $valuetoshow=$langs->trans("Country");
if ($fieldlist[$field]=='recuperableonly') $valuetoshow=$langs->trans("VATReceivedOnly");
// Affiche nom du champ
print_liste_field_titre($valuetoshow,"dict.php",$fieldlist[$field],"&id=".$_GET["id"],"","",$sortfield);

View File

@ -269,9 +269,9 @@ if ($id > 0)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Societe").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td align="center">'.$langs->trans("ContactType").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
@ -296,7 +296,7 @@ if ($id > 0)
print '<td colspan="1">';
$html->select_users($user->id,'contactid');
print '</td>';
print '<td align="center">';
print '<td>';
select_type_contact($contrat, '', 'type','internal');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
@ -325,7 +325,7 @@ if ($id > 0)
print '<td colspan="1">';
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid');
print '</td>';
print '<td align="center">';
print '<td>';
select_type_contact($contrat, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
@ -342,7 +342,7 @@ if ($id > 0)
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td align="center">'.$langs->trans("ContactType").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
@ -400,8 +400,8 @@ if ($id > 0)
}
print '</td>';
// Description
print '<td align="center">'.$tab[$i]['libelle'].'</td>';
// Type de contact
print '<td>'.$tab[$i]['libelle'].'</td>';
// Statut
print '<td align="center">';

View File

@ -1029,7 +1029,7 @@ class Contrat
if ($source == 'external') $sql.=" t.fk_soc as socid,";
if ($source == 'internal') $sql.=" t.name as nom,";
if ($source == 'external') $sql.=" t.name as nom,";
$sql.= "tc.code, tc.source, tc.libelle";
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,";
if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,";
@ -1054,7 +1054,8 @@ class Contrat
{
$obj = $this->db->fetch_object($resql);
$libelle_type=($langs->trans("TypeContact".$obj->code)!=$langs->trans("TypeContact".$obj->code) ? $langs->trans("TypeContact".$obj->code) : $obj->libelle);
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,
'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
$i++;
@ -1106,11 +1107,15 @@ class Contrat
*/
function liste_type_contact($source)
{
global $langs;
$element='contrat';
$tab = array();
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='contrat'";
$sql.= " WHERE element='".$element."'";
$sql.= " AND source='".$source."'";
$sql.= " ORDER by tc.code";
@ -1122,7 +1127,10 @@ class Contrat
while ($i < $num)
{
$obj = $this->db->fetch_object($result);
$tab[$obj->rowid]=$obj->libelle;
$transkey="TypeContact_".$element."_".$source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$obj->rowid]=$libelle_type;
$i++;
}
return $tab;

View File

@ -63,4 +63,10 @@ NbOfServices=Nb of services
CloseService=Close service
ServicesNomberShort=%s service(s)
RunningServices=Running services
BoardRunningServices=Expired running services
BoardRunningServices=Expired running services
##### Types de contacts #####
TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract
TypeContact_contrat_internal_SALESREPFOLL=Sales representative following-up contract
TypeContact_contrat_external_BILLING=Billing customer contact
TypeContact_contrat_external_CUSTOMER=Following-up customer contact
TypeContact_contrat_external_SALESREPSIGN=Signing contract customer contact

View File

@ -63,4 +63,10 @@ NbOfServices=Nb de services
CloseService=Fermer service
ServicesNomberShort=%s service(s)
RunningServices=Services actifs
BoardRunningServices=Services actifs expirés
BoardRunningServices=Services actifs expirés
##### Types de contacts #####
TypeContact_contrat_internal_SALESREPSIGN=Commercial signataire du contrat
TypeContact_contrat_internal_SALESREPFOLL=Commercial suivi du contrat
TypeContact_contrat_external_BILLING=Contact client facturation contrat
TypeContact_contrat_external_CUSTOMER=Contact client suivi contrat
TypeContact_contrat_external_SALESREPSIGN=Contact client signataire contrat

View File

@ -709,15 +709,17 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (10
--
-- Les types de contact d'un element
--
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (10, 'BILLING', 'contrat', 'Contact facturation du contrat', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (11, 'SALESREPSIGN', 'contrat', 'Commercial signataire du contrat', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (12, 'SALESREPFOLL', 'contrat', 'Commercial suivi du contrat', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (13, 'CUSTOMER', 'contrat', 'Contact client pour le contrat', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (20, 'BILLING', 'propal', 'Contact facturation de la propale', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (21, 'SALESREPSIGN', 'propal', 'Commercial signataire de la propale', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (22, 'SALESREPFOLL', 'propal', 'Commercial suivi de la propale', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (23, 'CUSTOMER', 'propal', 'Contact client pour la propale', 1);
insert into llx_c_type_contact(rowid, code, element, libelle, active ) values (80, 'PROJECTLEADER', 'projet', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (30, 'propal', 'internal', 'SALESREPSIGN', 'Commercial signataire de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial suivi de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'projet', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'projet', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);

View File

@ -1827,15 +1827,16 @@ ALTER TABLE llx_element_contact
FOREIGN KEY (fk_c_type_contact) REFERENCES llx_c_type_contact(rowid);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (10, 'contrat', 'external', 'BILLING', 'Contact facturation du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (12, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (13, 'contrat', 'external', 'CUSTOMER', 'Contact client pour le contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (20, 'propal', 'external', 'BILLING', 'Contact facturation de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (21, 'propal', 'internal', 'SALESREPSIGN', 'Commercial signataire de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (22, 'propal', 'internal', 'SALESREPFOLL', 'Commercial suivi de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (23, 'propal', 'external', 'CUSTOMER', 'Contact client pour la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (30, 'propal', 'internal', 'SALESREPSIGN', 'Commercial signataire de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial suivi de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'projet', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'projet', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);