29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
35 $langs->loadLangs(array(
"orders",
"companies"));
39 $action =
GETPOST(
'action',
'aZ09');
40 $massaction =
GETPOST(
'massaction',
'alpha');
42 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
43 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
44 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) {
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
61 $socid = $user->socid;
68 $hookmanager->initHooks(array(
'contactthirdparty',
'globalcard'));
75 if ($action ==
'addcontact' && $user->rights->societe->creer) {
76 $result = $object->fetch($id);
78 if ($result > 0 && $id > 0) {
81 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
85 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
88 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
89 $langs->load(
"errors");
90 $mesg =
'<div class="error">'.$langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType").
'</div>';
92 $mesg =
'<div class="error">'.$object->error.
'</div>';
95 } elseif ($action ==
'swapstatut' && $user->rights->societe->creer) {
97 if ($object->fetch($id)) {
98 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
102 } elseif ($action ==
'deletecontact' && $user->rights->societe->creer) {
105 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
108 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
120 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
127 $contactstatic =
new Contact($db);
128 $userstatic =
new User($db);
137 if ($id > 0 || !empty($ref)) {
138 if ($object->fetch($id, $ref) > 0) {
140 $soc->fetch($object->socid);
143 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"ThirdParty"), -1,
'company');
145 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'">';
146 print
'<input type="hidden" name="token" value="'.newToken().
'">';
148 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
150 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
152 print
'<div class="fichecenter">';
154 print
'<div class="underbanner clearboth"></div>';
155 print
'<table class="border centpercent">';
167 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
168 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
171 if ($object->client) {
172 print
'<tr><td class="titlefield">';
173 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
174 print $object->code_client;
175 $tmpcheck = $object->check_codeclient();
176 if ($tmpcheck != 0 && $tmpcheck != -5) {
177 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
182 if ($object->fournisseur) {
183 print
'<tr><td class="titlefield">';
184 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
185 print $object->code_fournisseur;
186 $tmpcheck = $object->check_codefournisseur();
187 if ($tmpcheck != 0 && $tmpcheck != -5) {
188 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
200 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
201 foreach ($dirtpls as $reldir) {
209 if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) {
210 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
211 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent_type.class.php';
216 $langs->load(
"members");
217 $sql =
"SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,";
218 $sql .=
" d.datefin,";
219 $sql .=
" d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
220 $sql .=
" t.libelle as type, t.subscription";
221 $sql .=
" FROM ".MAIN_DB_PREFIX.
"adherent as d";
222 $sql .=
", ".MAIN_DB_PREFIX.
"adherent_type as t";
223 $sql .=
" WHERE d.fk_soc = ".((int) $id);
224 $sql .=
" AND d.fk_adherent_type = t.rowid";
227 $resql = $db->query($sql);
229 $num = $db->num_rows(
$resql);
234 $titre = $langs->trans(
"MembersListOfTiers");
237 print_barre_liste($titre, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, 0,
'');
239 print
"<table class=\"noborder\" width=\"100%\">";
240 print
'<tr class="liste_titre">';
242 print_liste_field_titre(
"NameSlashCompany", $_SERVER[
"PHP_SELF"],
"d.lastname", $param,
"",
"", $sortfield, $sortorder);
247 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"d.statut,d.datefin", $param,
"",
"", $sortfield, $sortorder);
248 print_liste_field_titre(
"EndSubscription", $_SERVER[
"PHP_SELF"],
"d.datefin", $param,
"",
'', $sortfield, $sortorder,
'center ');
252 while ($i < $num && $i < $conf->liste_limit) {
253 $objp = $db->fetch_object(
$resql);
255 $datefin = $db->jdate($objp->datefin);
256 $memberstatic->id = $objp->rowid;
257 $memberstatic->ref = $objp->rowid;
258 $memberstatic->lastname = $objp->lastname;
259 $memberstatic->firstname = $objp->firstname;
260 $memberstatic->statut = $objp->statut;
261 $memberstatic->datefin = $db->jdate($objp->datefin);
263 $companyname = $objp->company;
265 print
'<tr class="oddeven">';
269 print $memberstatic->getNomUrl(1);
273 print
"<td><a href=\"card.php?rowid=$objp->rowid\">";
274 print ((!empty($objp->lastname) || !empty($objp->firstname)) ?
dol_trunc($memberstatic->getFullName($langs)) :
'');
275 print (((!empty($objp->lastname) || !empty($objp->firstname)) && !empty($companyname)) ?
' / ' :
'');
276 print (!empty($companyname) ?
dol_trunc($companyname, 32) :
'');
280 print
"<td>".$objp->login.
"</td>\n";
283 $membertypestatic->id = $objp->type_id;
284 $membertypestatic->libelle = $objp->type;
285 $membertypestatic->label = $objp->type;
287 print
'<td class="nowrap">';
288 print $membertypestatic->getNomUrl(1, 32);
292 print
"<td>".$memberstatic->getmorphylib($objp->morphy).
"</td>\n";
295 print
"<td>".dol_print_email($objp->email, 0, 0, 1).
"</td>\n";
298 print
'<td class="nowrap">';
299 print $memberstatic->LibStatut($objp->statut, $objp->subscription, $datefin, 2);
304 print
'<td class="center nowrap">';
306 if ($memberstatic->hasDelay()) {
307 print
" ".img_warning($langs->trans(
"SubscriptionLate"));
311 print
'<td class="left nowrap">';
312 if (!empty($objp->subscription)) {
313 print $langs->trans(
"SubscriptionNotReceived");
314 if ($objp->statut > 0) {
315 print
" ".img_warning();
332 print
"ErrorRecordNotFound";