Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
75e2350e
Commit
75e2350e
authored
11 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Mutualizing code fix bug into duplicate code of contact management
for project.
parent
db8af861
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/core/tpl/contacts.tpl.php
+4
-0
4 additions, 0 deletions
htdocs/core/tpl/contacts.tpl.php
htdocs/projet/contact.php
+43
-228
43 additions, 228 deletions
htdocs/projet/contact.php
with
47 additions
and
228 deletions
htdocs/core/tpl/contacts.tpl.php
+
4
−
0
View file @
75e2350e
...
...
@@ -14,6 +14,9 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* This template needs:
* $object
*/
if
(
!
class_exists
(
'Contact'
))
{
...
...
@@ -30,6 +33,7 @@ if ($module == 'propal') { $permission=$user->rights->propale->creer; }
elseif
(
$module
==
'fichinter'
)
{
$permission
=
$user
->
rights
->
ficheinter
->
creer
;
}
elseif
(
$module
==
'invoice_supplier'
)
{
$permission
=
$user
->
rights
->
fournisseur
->
facture
->
creer
;
}
elseif
(
$module
==
'order_supplier'
)
{
$permission
=
$user
->
rights
->
fournisseur
->
commande
->
creer
;
}
elseif
(
$module
==
'project'
)
{
$permission
=
$user
->
rights
->
projet
->
creer
;
}
elseif
(
!
isset
(
$permission
))
{
$permission
=
$user
->
rights
->
$module
->
creer
;
}
// If already defined by caller page
$formcompany
=
new
FormCompany
(
$db
);
...
...
This diff is collapsed.
Click to expand it.
htdocs/projet/contact.php
+
43
−
228
View file @
75e2350e
...
...
@@ -33,15 +33,18 @@ $langs->load("companies");
$id
=
GETPOST
(
'id'
,
'int'
);
$ref
=
GETPOST
(
'ref'
,
'alpha'
);
$lineid
=
GETPOST
(
'lineid'
,
'int'
);
$socid
=
GETPOST
(
'socid'
,
'int'
);
$action
=
GETPOST
(
'action'
,
'alpha'
);
$mine
=
$_REQUE
ST
[
'mode'
]
==
'mine'
?
1
:
0
;
$mine
=
GETPO
ST
(
'mode'
)
==
'mine'
?
1
:
0
;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
$
pr
oject
=
new
Project
(
$db
);
$o
b
ject
=
new
Project
(
$db
);
if
(
$ref
)
{
$
pr
oject
->
fetch
(
0
,
$ref
);
$id
=
$
pr
oject
->
id
;
$o
b
ject
->
fetch
(
0
,
$ref
);
$id
=
$o
b
ject
->
id
;
}
// Security check
...
...
@@ -55,41 +58,42 @@ $result = restrictedArea($user, 'projet', $id);
*/
// Add new contact
if
(
$
_POST
[
"
action
"
]
==
'addcontact'
&&
$user
->
rights
->
projet
->
creer
)
if
(
$action
==
'addcontact'
&&
$user
->
rights
->
projet
->
creer
)
{
$result
=
0
;
$result
=
$
pr
oject
->
fetch
(
$id
);
$result
=
$o
b
ject
->
fetch
(
$id
);
if
(
$result
>
0
&&
$id
>
0
)
{
$result
=
$project
->
add_contact
(
$_POST
[
"contactid"
],
$_POST
[
"type"
],
$_POST
[
"source"
]);
$contactid
=
(
GETPOST
(
'userid'
)
?
GETPOST
(
'userid'
,
'int'
)
:
GETPOST
(
'contactid'
,
'int'
));
$result
=
$object
->
add_contact
(
$contactid
,
$_POST
[
"type"
],
$_POST
[
"source"
]);
}
if
(
$result
>=
0
)
{
header
(
"Location:
contact.php
?id="
.
$
pr
oject
->
id
);
header
(
"Location:
"
.
$_SERVER
[
'PHP_SELF'
]
.
"
?id="
.
$o
b
ject
->
id
);
exit
;
}
else
{
if
(
$
pr
oject
->
error
==
'DB_ERROR_RECORD_ALREADY_EXISTS'
)
if
(
$o
b
ject
->
error
==
'DB_ERROR_RECORD_ALREADY_EXISTS'
)
{
$langs
->
load
(
"errors"
);
$mesg
=
'<div class="error">'
.
$langs
->
trans
(
"ErrorThisContactIsAlreadyDefinedAsThisType"
)
.
'</div>'
;
}
else
{
$mesg
=
'<div class="error">'
.
$
pr
oject
->
error
.
'</div>'
;
$mesg
=
'<div class="error">'
.
$o
b
ject
->
error
.
'</div>'
;
}
}
}
// bascule du statut d'un contact
if
(
$
_GET
[
"
action
"
]
==
'swapstatut'
&&
$user
->
rights
->
projet
->
creer
)
if
(
$action
==
'swapstatut'
&&
$user
->
rights
->
projet
->
creer
)
{
if
(
$
pr
oject
->
fetch
(
$id
))
if
(
$o
b
ject
->
fetch
(
$id
))
{
$result
=
$
pr
oject
->
swapContactStatus
(
GETPOST
(
'ligne'
));
$result
=
$o
b
ject
->
swapContactStatus
(
GETPOST
(
'ligne'
));
}
else
{
...
...
@@ -98,14 +102,14 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->projet->creer)
}
// Efface un contact
if
(
$
_GET
[
"
action
"
]
==
'deleteline'
&&
$user
->
rights
->
projet
->
creer
)
if
(
(
$action
==
'deleteline'
||
$action
==
'deletecontact'
)
&&
$user
->
rights
->
projet
->
creer
)
{
$
pr
oject
->
fetch
(
$id
);
$result
=
$
pr
oject
->
delete_contact
(
$_GET
[
"lineid"
]);
$o
b
ject
->
fetch
(
$id
);
$result
=
$o
b
ject
->
delete_contact
(
$_GET
[
"lineid"
]);
if
(
$result
>=
0
)
{
header
(
"Location: contact.php?id="
.
$
pr
oject
->
id
);
header
(
"Location: contact.php?id="
.
$o
b
ject
->
id
);
exit
;
}
else
...
...
@@ -137,18 +141,18 @@ dol_htmloutput_mesg($mesg);
if
(
$id
>
0
||
!
empty
(
$ref
))
{
if
(
$
pr
oject
->
fetch
(
$id
,
$ref
)
>
0
)
if
(
$o
b
ject
->
fetch
(
$id
,
$ref
)
>
0
)
{
if
(
$
pr
oject
->
societe
->
id
>
0
)
$result
=
$
pr
oject
->
societe
->
fetch
(
$
pr
oject
->
societe
->
id
);
if
(
$o
b
ject
->
societe
->
id
>
0
)
$result
=
$o
b
ject
->
societe
->
fetch
(
$o
b
ject
->
societe
->
id
);
// To verify role of users
//$userAccess = $
pr
oject->restrictedProjectArea($user,'read');
$userWrite
=
$
pr
oject
->
restrictedProjectArea
(
$user
,
'write'
);
//$userDelete = $
pr
oject->restrictedProjectArea($user,'delete');
//$userAccess = $o
b
ject->restrictedProjectArea($user,'read');
$userWrite
=
$o
b
ject
->
restrictedProjectArea
(
$user
,
'write'
);
//$userDelete = $o
b
ject->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
$head
=
project_prepare_head
(
$
pr
oject
);
dol_fiche_head
(
$head
,
'contact'
,
$langs
->
trans
(
"Project"
),
0
,
(
$
pr
oject
->
public
?
'projectpub'
:
'project'
));
$head
=
project_prepare_head
(
$o
b
ject
);
dol_fiche_head
(
$head
,
'contact'
,
$langs
->
trans
(
"Project"
),
0
,
(
$o
b
ject
->
public
?
'projectpub'
:
'project'
));
/*
...
...
@@ -163,231 +167,42 @@ if ($id > 0 || ! empty($ref))
// Define a complementary filter for search of next/prev ref.
if
(
!
$user
->
rights
->
projet
->
all
->
lire
)
{
$
pr
ojectsListId
=
$
pr
oject
->
getProjectsAuthorizedForUser
(
$user
,
$mine
,
0
);
$
pr
oject
->
next_prev_filter
=
" rowid in ("
.
(
count
(
$
pr
ojectsListId
)
?
join
(
','
,
array_keys
(
$
pr
ojectsListId
))
:
'0'
)
.
")"
;
$o
b
jectsListId
=
$o
b
ject
->
getProjectsAuthorizedForUser
(
$user
,
$mine
,
0
);
$o
b
ject
->
next_prev_filter
=
" rowid in ("
.
(
count
(
$o
b
jectsListId
)
?
join
(
','
,
array_keys
(
$o
b
jectsListId
))
:
'0'
)
.
")"
;
}
print
$form
->
showrefnav
(
$
pr
oject
,
'ref'
,
$linkback
,
1
,
'ref'
,
'ref'
,
''
);
print
$form
->
showrefnav
(
$o
b
ject
,
'ref'
,
$linkback
,
1
,
'ref'
,
'ref'
,
''
);
print
'</td></tr>'
;
// Label
print
'<tr><td>'
.
$langs
->
trans
(
"Label"
)
.
'</td><td>'
.
$
pr
oject
->
title
.
'</td></tr>'
;
print
'<tr><td>'
.
$langs
->
trans
(
"Label"
)
.
'</td><td>'
.
$o
b
ject
->
title
.
'</td></tr>'
;
// Customer
print
"<tr><td>"
.
$langs
->
trans
(
"Company"
)
.
"</td>"
;
print
'<td colspan="3">'
;
if
(
$
pr
oject
->
societe
->
id
>
0
)
print
$
pr
oject
->
societe
->
getNomUrl
(
1
);
if
(
$o
b
ject
->
societe
->
id
>
0
)
print
$o
b
ject
->
societe
->
getNomUrl
(
1
);
else
print
' '
;
print
'</td></tr>'
;
// Visibility
print
'<tr><td>'
.
$langs
->
trans
(
"Visibility"
)
.
'</td><td>'
;
if
(
$
pr
oject
->
public
)
print
$langs
->
trans
(
'SharedProject'
);
if
(
$o
b
ject
->
public
)
print
$langs
->
trans
(
'SharedProject'
);
else
print
$langs
->
trans
(
'PrivateProject'
);
print
'</td></tr>'
;
// Statut
print
'<tr><td>'
.
$langs
->
trans
(
"Status"
)
.
'</td><td>'
.
$
pr
oject
->
getLibStatut
(
4
)
.
'</td></tr>'
;
print
'<tr><td>'
.
$langs
->
trans
(
"Status"
)
.
'</td><td>'
.
$o
b
ject
->
getLibStatut
(
4
)
.
'</td></tr>'
;
print
"</table>"
;
print
'</div>'
;
/*
* Lignes de contacts
*/
print
'<br><table class="noborder" width="100%">'
;
/*
* Ajouter une ligne de contact
* Non affiche en mode modification de ligne
*/
if
(
$_GET
[
"action"
]
!=
'editline'
)
{
print
'<tr class="liste_titre">'
;
print
'<td>'
.
$langs
->
trans
(
"Source"
)
.
'</td>'
;
print
'<td>'
.
$langs
->
trans
(
"Company"
)
.
'</td>'
;
print
'<td>'
.
$langs
->
trans
(
"Contacts"
)
.
'</td>'
;
print
'<td>'
.
$langs
->
trans
(
"ContactType"
)
.
'</td>'
;
print
'<td colspan="3"> </td>'
;
print
"</tr>
\n
"
;
$var
=
false
;
print
'<form action="'
.
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$project
->
id
.
'" method="POST">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="addcontact">'
;
print
'<input type="hidden" name="source" value="internal">'
;
print
'<input type="hidden" name="id" value="'
.
$project
->
id
.
'">'
;
// Ligne ajout pour contact interne
print
"<tr "
.
$bc
[
$var
]
.
">"
;
print
'<td class="nowrap">'
;
print
img_object
(
''
,
'user'
)
.
' '
.
$langs
->
trans
(
"Users"
);
print
'</td>'
;
print
'<td colspan="1">'
;
print
$conf
->
global
->
MAIN_INFO_SOCIETE_NOM
;
print
'</td>'
;
print
'<td colspan="1">'
;
// On recupere les id des users deja selectionnes
$form
->
select_users
(
$user
->
id
,
'contactid'
,
0
);
print
'</td>'
;
print
'<td>'
;
$formcompany
->
selectTypeContact
(
$project
,
''
,
'type'
,
'internal'
,
'rowid'
);
print
'</td>'
;
print
'<td align="right" colspan="3" >'
;
if
(
$userWrite
>
0
||
$user
->
admin
)
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls
=
array_merge
(
$conf
->
modules_parts
[
'tpl'
],
array
(
'/core/tpl'
));
foreach
(
$dirtpls
as
$reldir
)
{
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Add"
)
.
'"'
;
if
(
!
(
$userWrite
>
0
||
$user
->
admin
))
print
' disabled="disabled"'
;
print
'>'
;
}
print
'</td>'
;
print
'</tr>'
;
print
'</form>'
;
// Line to add external contact. Only if project is linked to a third party.
//if ($project->societe->id)
//{
print
'<form action="'
.
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$id
.
'" method="POST">'
;
print
'<input type="hidden" name="token" value="'
.
$_SESSION
[
'newtoken'
]
.
'">'
;
print
'<input type="hidden" name="action" value="addcontact">'
;
print
'<input type="hidden" name="source" value="external">'
;
print
'<input type="hidden" name="id" value="'
.
$id
.
'">'
;
$var
=!
$var
;
print
"<tr "
.
$bc
[
$var
]
.
">"
;
print
'<td class="nowrap">'
;
print
img_object
(
''
,
'contact'
)
.
' '
.
$langs
->
trans
(
"ThirdPartyContacts"
);
print
'</td>'
;
print
'<td colspan="1">'
;
$selectedCompany
=
isset
(
$_GET
[
"newcompany"
])
?
$_GET
[
"newcompany"
]
:
$project
->
societe
->
id
;
$selectedCompany
=
$formcompany
->
selectCompaniesForNewContact
(
$project
,
'id'
,
$selectedCompany
,
'newcompany'
,
(
empty
(
$project
->
societe
->
id
)
?
array
()
:
array
(
$project
->
societe
->
id
)));
print
'</td>'
;
print
'<td colspan="1">'
;
$nbofcontacts
=
$form
->
select_contacts
(
$selectedCompany
,
''
,
'contactid'
);
//if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print
'</td>'
;
print
'<td>'
;
$formcompany
->
selectTypeContact
(
$project
,
''
,
'type'
,
'external'
,
'rowid'
);
print
'</td>'
;
print
'<td align="right" colspan="3" >'
;
if
(
$userWrite
>
0
||
$user
->
admin
)
{
print
'<input type="submit" class="button" value="'
.
$langs
->
trans
(
"Add"
)
.
'"'
;
if
(
!
$nbofcontacts
||
!
(
$userWrite
>
0
||
$user
->
admin
))
print
' disabled="disabled"'
;
print
'>'
;
}
print
'</td>'
;
print
'</tr>'
;
print
"</form>"
;
//}
print
'<tr><td colspan="6"> </td></tr>'
;
$res
=@
include
dol_buildpath
(
$reldir
.
'/contacts.tpl.php'
);
if
(
$res
)
break
;
}
// Liste des contacts lies
print
'<tr class="liste_titre">'
;
print
'<td>'
.
$langs
->
trans
(
"Source"
)
.
'</td>'
;
print
'<td>'
.
$langs
->
trans
(
"Company"
)
.
'</td>'
;
print
'<td>'
.
$langs
->
trans
(
"Contacts"
)
.
'</td>'
;
print
'<td>'
.
$langs
->
trans
(
"ContactType"
)
.
'</td>'
;
print
'<td align="center">'
.
$langs
->
trans
(
"Status"
)
.
'</td>'
;
print
'<td colspan="2"> </td>'
;
print
"</tr>
\n
"
;
$companystatic
=
new
Societe
(
$db
);
$var
=
true
;
foreach
(
array
(
'internal'
,
'external'
)
as
$source
)
{
$tab
=
$project
->
liste_contact
(
-
1
,
$source
);
$num
=
count
(
$tab
);
$i
=
0
;
while
(
$i
<
$num
)
{
$var
=
!
$var
;
print
'<tr '
.
$bc
[
$var
]
.
' valign="top">'
;
// Source
print
'<td align="left">'
;
if
(
$tab
[
$i
][
'source'
]
==
'internal'
)
print
$langs
->
trans
(
"User"
);
if
(
$tab
[
$i
][
'source'
]
==
'external'
)
print
$langs
->
trans
(
"ThirdPartyContact"
);
print
'</td>'
;
// Societe
print
'<td align="left">'
;
if
(
$tab
[
$i
][
'socid'
]
>
0
)
{
$companystatic
->
fetch
(
$tab
[
$i
][
'socid'
]);
print
$companystatic
->
getNomUrl
(
1
);
}
if
(
$tab
[
$i
][
'socid'
]
<
0
)
{
print
$conf
->
global
->
MAIN_INFO_SOCIETE_NOM
;
}
if
(
!
$tab
[
$i
][
'socid'
])
{
print
' '
;
}
print
'</td>'
;
// Contact
print
'<td>'
;
if
(
$tab
[
$i
][
'source'
]
==
'internal'
)
{
$userstatic
->
id
=
$tab
[
$i
][
'id'
];
$userstatic
->
lastname
=
$tab
[
$i
][
'nom'
];
$userstatic
->
firstname
=
$tab
[
$i
][
'firstname'
];
print
$userstatic
->
getNomUrl
(
1
);
}
if
(
$tab
[
$i
][
'source'
]
==
'external'
)
{
$contactstatic
->
id
=
$tab
[
$i
][
'id'
];
$contactstatic
->
lastname
=
$tab
[
$i
][
'nom'
];
$contactstatic
->
firstname
=
$tab
[
$i
][
'firstname'
];
print
$contactstatic
->
getNomUrl
(
1
);
}
print
'</td>'
;
// Type de contact
print
'<td>'
.
$tab
[
$i
][
'libelle'
]
.
'</td>'
;
// Statut
print
'<td align="center">'
;
// Activation desativation du contact
if
(
$project
->
statut
>=
0
&&
$userWrite
>
0
)
print
'<a href="'
.
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$project
->
id
.
'&action=swapstatut&ligne='
.
$tab
[
$i
][
'rowid'
]
.
'">'
;
print
$contactstatic
->
LibStatut
(
$tab
[
$i
][
'status'
],
3
);
if
(
$project
->
statut
>=
0
&&
$userWrite
>
0
)
print
'</a>'
;
print
'</td>'
;
// Icon update et delete
print
'<td align="center" nowrap>'
;
if
(
$user
->
rights
->
projet
->
creer
&&
$userWrite
>
0
)
{
print
' '
;
print
'<a href="'
.
$_SERVER
[
"PHP_SELF"
]
.
'?id='
.
$project
->
id
.
'&action=deleteline&lineid='
.
$tab
[
$i
][
'rowid'
]
.
'">'
;
print
img_delete
();
print
'</a>'
;
}
print
'</td>'
;
print
"</tr>
\n
"
;
$i
++
;
}
}
print
"</table>"
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment