32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contact.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
48 $langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
50 $mesg =
''; $error = 0; $errors = array();
52 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
53 $confirm =
GETPOST(
'confirm',
'alpha');
54 $backtopage =
GETPOST(
'backtopage',
'alpha');
56 $socid =
GETPOST(
'socid',
'int');
62 $extrafields->fetch_name_optionals_label($object->table_element);
65 $object->getCanvas($id);
67 $canvas = (!empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas"));
70 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
71 $objcanvas =
new Canvas($db, $action);
72 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
75 if (
GETPOST(
'actioncode',
'array'))
77 $actioncode =
GETPOST(
'actioncode',
'array', 3);
78 if (!count($actioncode)) $actioncode =
'0';
80 $actioncode =
GETPOST(
"actioncode",
"alpha", 3) ?
GETPOST(
"actioncode",
"alpha", 3) : (
GETPOST(
"actioncode") ==
'0' ?
'0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ?
'' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
82 $search_agenda_label =
GETPOST(
'search_agenda_label');
85 if ($user->socid) $socid = $user->socid;
86 $result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
88 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
89 $sortfield =
GETPOST(
"sortfield",
'alpha');
90 $sortorder =
GETPOST(
"sortorder",
'alpha');
92 if (empty($page) || $page == -1) { $page = 0; }
93 $offset = $limit * $page;
94 $pageprev = $page - 1;
95 $pagenext = $page + 1;
96 if (!$sortfield) $sortfield =
'a.datep, a.id';
97 if (!$sortorder) $sortorder =
'DESC';
100 $hookmanager->initHooks(array(
'contactagenda',
'globalcard'));
107 $parameters = array(
'id'=>$id,
'objcanvas'=>$objcanvas);
108 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
109 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
114 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage))
116 header(
"Location: ".$backtopage);
121 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
124 $search_agenda_label =
'';
133 $form =
new Form($db);
135 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
136 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
137 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
144 $objsoc->fetch($socid);
147 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
152 if (empty($object->error) && $id)
155 $result = $object->fetch($id);
158 $objcanvas->assign_values($action, $object->id, $object->ref);
159 $objcanvas->display_canvas($action);
166 if ($user->rights->societe->contact->supprimer)
168 if ($action ==
'delete')
170 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
182 $res = $object->fetch($id, $user);
184 $res = $object->fetch_optionals();
190 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
193 if (!empty($id) && $action !=
'edit' && $action !=
'create')
205 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
207 $morehtmlref =
'<div class="refidno">';
208 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
211 $objsoc->fetch($object->socid);
213 $morehtmlref .= $langs->trans(
'ThirdParty').
' : ';
214 if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1);
215 else $morehtmlref .= $langs->trans(
"ContactNotLinkedToCompany");
217 $morehtmlref .=
'</div>';
219 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
221 print '<div class="fichecenter">';
223 print '<div class="underbanner clearboth"></div>';
236 $object->fetch_thirdparty();
237 $objthirdparty = $object->thirdparty;
240 $permok = $user->rights->agenda->myactions->create;
241 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
243 if (is_object($objthirdparty) && get_class($objthirdparty) ==
'Societe') $out .=
'&originid='.$objthirdparty->id.($objthirdparty->id > 0 ?
'&socid='.$objthirdparty->id :
'');
244 $out .= (!empty($objcon->id) ?
'&contactid='.$objcon->id :
'').
'&origin=contact&originid='.$object->id.
'&percentage=-1&backtopage='.urlencode(
$_SERVER[
'PHP_SELF'].($objcon->id > 0 ?
'?id='.$objcon->id :
''));
249 if (!empty($conf->agenda->enabled))
251 if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
253 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'AddAction'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/comm/action/card.php?action=create'.$out);
257 if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
262 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.$contextpage;
263 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.$limit;
270 $filters[
'search_agenda_label'] = $search_agenda_label;
272 show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode,
'', $filters, $sortfield, $sortorder);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_now($mode= 'auto')
Return date for now.
dol_print_object_info($object, $usetable=0)
Show informations on an object TODO Move this into html.formother.
show_actions_done($conf, $langs, $db, $filterobj, $objcon= '', $noprint=0, $actioncode= '', $donetodo= 'done', $filters=array(), $sortfield= 'a.datep, a.id', $sortorder= 'DESC', $module= '')
Show html area with actions (done or not, ignore the name of function).
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).