Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
usercard_tab.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* State document edition
9
*
10
* @author Anakeen 2000
11
* @version $Id: usercard_tab.php,v 1.7 2005/05/19 14:38:44 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage
15
*/
16
/**
17
*/
18
19
include_once (
"FDL/Class.WDoc.php"
);
20
include_once (
"Class.QueryDb.php"
);
21
include_once (
"FDL/freedom_util.php"
);
22
include_once (
"FDL/editutil.php"
);
23
include_once (
"FDL/editcard.php"
);
24
// -----------------------------------
25
function
usercard_tab
(&
$action
)
26
{
27
$dbaccess
=
$action
->GetParam(
"FREEDOM_DB"
);
28
$sdoc =
createDoc
(
$dbaccess
, 5,
false
);
//new DocSearch($dbaccess);
29
$sdoc->doctype =
'T'
;
// it is a temporary document (will be delete after)
30
$sdoc->Add();
31
32
$default =
GetHttpVars
(
"default"
,
"Y"
);
33
$fam =
"USER"
;
34
35
if
($default ==
"N"
) {
36
$fam =
GetHttpVars
(
"family"
);
37
}
38
39
$famid
=
getFamIdFromName
(
$dbaccess
, $fam);
40
// $sdoc->title=sprintf(_("%s"),getTitle($famid));
41
$sdoc->title = _($fam);
42
$sqlfilter[] =
"(fromid=$famid)"
;
43
//filters for USER or IUSER
44
if
(($fam ==
"USER"
or $fam ==
"IUSER"
) and $default ==
"N"
) {
45
//criteres
46
$contact =
GetHttpVars
(
"contact"
);
47
$Tcontact = explode(
" "
, $contact);
48
$ch =
""
;
49
foreach
($Tcontact as $k => $v) {
50
if
($ch <>
""
) $ch.=
" and "
;
51
$ch.=
" title ~* '$Tcontact[$k]'"
;
52
}
53
if
($contact <>
""
) $sqlfilter[] =
"$ch or us_mail ~* '$contact' "
;
54
55
$society =
GetHttpVars
(
"society"
);
56
$Tsoc = explode(
" "
, $society);
57
$ch =
""
;
58
foreach
($Tsoc as $k => $v) {
59
if
($ch <>
""
) $ch.=
" and "
;
60
$ch.=
" us_society ~* '$Tsoc[$k]'"
;
61
}
62
if
($society <>
""
) $sqlfilter[] =
"$ch"
;
63
64
$private =
GetHttpVars
(
"private"
);
65
if
($private == 1) $sqlfilter[] =
"us_privcard='P' "
;
66
//details
67
$allcond =
GetHttpVars
(
"allcond"
);
68
if
($allcond == 1) $op =
"and"
;
69
else
$op =
"or"
;
70
71
$mail =
GetHttpVars
(
"mail"
);
72
$phone =
GetHttpVars
(
"phone"
);
73
$pphone =
GetHttpVars
(
"pphone"
);
74
$mobile =
GetHttpVars
(
"mobile"
);
75
$adr =
GetHttpVars
(
"adr"
);
76
$postalcode =
GetHttpVars
(
"postalcode"
);
77
$town =
GetHttpVars
(
"town"
);
78
$country =
GetHttpVars
(
"country"
);
79
$function =
GetHttpVars
(
"function"
);
80
$catg =
GetHttpVars
(
"catg"
);
81
82
$sql
= array();
83
if
($mail <>
""
)
$sql
[] =
" us_mail ~* '$mail'"
;
84
if
($phone <>
""
)
$sql
[] =
" us_phone ~* '$phone'"
;
85
if
($pphone <>
""
)
$sql
[] =
" us_pphone ~* '$pphone'"
;
86
if
($mobile <>
""
)
$sql
[] =
" us_mobile ~* '$mobile'"
;
87
if
($adr <>
""
)
$sql
[] =
" us_workaddr ~* '$adr'"
;
88
if
($postalcode <>
""
)
$sql
[] =
" us_workpostalcode ~* '$postalcode'"
;
89
if
($town <>
""
)
$sql
[] =
" us_worktown ~* '$town'"
;
90
if
($country <>
""
)
$sql
[] =
"us_country ~* '$country'"
;
91
if
($function <>
""
)
$sql
[] =
"us_type ~* '$function'"
;
92
if
($catg <>
""
)
$sql
[] =
"us_scatg ~* '$catg'"
;
93
94
$ch =
""
;
95
foreach
(
$sql
as $k => $v) {
96
if
($ch <>
""
) $ch.=
" $op "
;
97
$ch.=
$sql
[$k];
98
}
99
100
if
($ch <>
""
) $sqlfilter[] = $ch;
101
}
102
//filters for SOCIETY
103
if
($fam ==
"SOCIETY"
and $default ==
"N"
) {
104
//criteres
105
$society =
GetHttpVars
(
"society"
);
106
$Tsoc = explode(
" "
, $society);
107
$ch =
""
;
108
foreach
($Tsoc as $k => $v) {
109
if
($ch <>
""
) $ch.=
" and "
;
110
$ch.=
" si_society ~* '$Tsoc[$k]'"
;
111
}
112
if
($society <>
""
) $sqlfilter[] =
"$ch"
;
113
//details
114
$allcond =
GetHttpVars
(
"allcond"
);
115
if
($allcond == 1) $op =
"and"
;
116
else
$op =
"or"
;
117
118
$phone =
GetHttpVars
(
"phone"
);
119
$adr =
GetHttpVars
(
"adr"
);
120
$catg =
GetHttpVars
(
"catg"
);
121
$postalcode =
GetHttpVars
(
"postalcode"
);
122
$town =
GetHttpVars
(
"town"
);
123
$country =
GetHttpVars
(
"country"
);
124
125
$sql
= array();
126
if
($phone <>
""
)
$sql
[] =
" si_phone ~* '$phone'"
;
127
if
($adr <>
""
)
$sql
[] =
" si_addr ~* '$adr'"
;
128
if
($postalcode <>
""
)
$sql
[] =
" si_postalcode ~* '$postalcode'"
;
129
if
($town <>
""
)
$sql
[] =
" si_town ~* '$town'"
;
130
if
($country <>
""
)
$sql
[] =
" si_country ~* '$country'"
;
131
if
($catg <>
""
)
$sql
[] =
"si_catg ~* '$catg'"
;
132
133
$ch =
""
;
134
foreach
(
$sql
as $k => $v) {
135
if
($ch <>
""
) $ch.=
" $op "
;
136
$ch.=
$sql
[$k];
137
}
138
139
if
($ch <>
""
) $sqlfilter[] = $ch;
140
}
141
//REQUETE
142
$query
=
getSqlSearchDoc
(
$dbaccess
, $sdirid,
$famid
, $sqlfilter);
143
144
$sdoc->AddQuery(
$query
);
145
redirect(
$action
,
"FREEDOM"
,
"FREEDOM_LISTDETAIL&dirid="
. $sdoc->id .
"&catg=0"
);
146
}
147
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase