27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/website/lib/websiteaccount.lib.php';
42$langs->loadLangs(array(
"companies",
"website",
"other"));
45$action =
GETPOST(
'action',
'aZ09');
46$confirm =
GETPOST(
'confirm',
'alpha');
48$backtopage =
GETPOST(
'backtopage',
'alpha');
57$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
60$extrafields->fetch_name_optionals_label(
$object->table_element);
62$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
65$search_all =
GETPOST(
"search_all",
'alpha');
67foreach (
$object->fields as $key => $val) {
68 if (
GETPOST(
'search_'.$key,
'alpha')) {
69 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
73if (empty($action) && empty($id) && empty($ref)) {
78include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
85if (!$permissiontoaccess) {
90$permissiontocreate = 0;
91$permissiontodelete = 0;
94 if (
$object->site ==
'dolibarr_website') {
95 $permissiontocreate =
isModEnabled(
'website') && $user->hasRight(
'website',
'write');
96 $permissiontodelete =
isModEnabled(
'website') && $user->hasRight(
'website',
'delete');
97 } elseif (
$object->site ==
'dolibarr_portal') {
98 $permissiontocreate = $permissiontodelete =
isModEnabled(
'webportal') && $user->hasRight(
'webportal',
'write');
101 $permissiontocreate =
isModEnabled(
'website') && $user->hasRight(
'website',
'write') ||
isModEnabled(
'webportal') && $user->hasRight(
'webportal',
'write');
103$permissionnote = $permissiontocreate;
104$permissiondellink = $permissiontocreate;
105$permissiontoadd = $permissiontocreate;
109if (!empty($action) && $action !=
'view') {
110 if (!empty(
$object->fields[
'site'][
'arrayofkeyval'])) {
111 if (isset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_website'])) {
112 if ($action ==
'delete' || $action ==
'confirm_delete') {
113 if (!$user->hasRight(
'website',
'delete')) {
114 unset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_website']);
117 if (!$user->hasRight(
'website',
'write')) {
118 unset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_website']);
123 if (isset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_portal'])) {
124 if (!$user->hasRight(
'webportal',
'write')) {
125 unset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_portal']);
129 if (empty(
$object->fields[
'site'][
'arrayofkeyval'])) {
135 if (!array_key_exists(
$object->site,
$object->fields[
'site'][
'arrayofkeyval'])) {
148$parameters = array();
149$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
154if (empty($reshook)) {
157 if ($action ==
'add' && !
GETPOST(
'site')) {
158 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Website")),
null,
'errors');
163 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
166 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
169 $triggersendname =
'WEBSITEACCOUNT_SENTBYMAIL';
170 $autocopy =
'MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO';
171 $trackid =
'websiteaccount'.$object->id;
172 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
180$form =
new Form($db);
183$title = $langs->trans(
"WebsiteAccount");
186llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-website page-card_websiteaccount');
190if ($action ==
'create' || $action ==
'edit') {
191 if (!empty(
$object->fields[
'site'][
'visible']) && !empty(
$object->fields[
'fk_website'][
'visible'])) {
192 $site_type_js =
'function siteTypeChange(site_type) {';
193 $site_type_js .=
' if (site_type == "dolibarr_website") {';
194 $site_type_js .=
' jQuery("tr.field_fk_website").show();';
195 $site_type_js .=
' } else {';
196 $site_type_js .=
' jQuery("select#fk_website").val("-1").change();';
197 $site_type_js .=
' jQuery("tr.field_fk_website").hide();';
198 $site_type_js .=
' }';
199 $site_type_js .=
'}';
200 $site_type_js .=
'jQuery(document).ready(function(){';
201 $site_type_js .=
' siteTypeChange(jQuery("#site").val());';
202 $site_type_js .=
' jQuery("#site").change(function(){';
203 $site_type_js .=
' siteTypeChange(this.value);';
204 $site_type_js .=
' });';
205 $site_type_js .=
'});';
207 $out_js .=
'<script type"text/javascript">';
208 $out_js .= $site_type_js;
209 $out_js .=
'</script>';
214if ($action ==
'create') {
215 if (empty($permissiontoadd)) {
219 print
load_fiche_titre($langs->trans(
"NewWebsiteAccount", $langs->transnoentitiesnoconv(
"WebsiteAccount")));
221 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
222 print
'<input type="hidden" name="token" value="'.newToken().
'">';
223 print
'<input type="hidden" name="action" value="add">';
225 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
227 if (!empty($backtopageforcancel)) {
228 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
230 if (!empty($dol_openinpopup)) {
231 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
236 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
239 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
242 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
244 print
'</table>'.
"\n";
248 print $form->buttonsSaveCancel(
"Create");
256if (($id || $ref) && $action ==
'edit') {
259 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
260 print
'<input type="hidden" name="token" value="'.newToken().
'">';
261 print
'<input type="hidden" name="action" value="update">';
262 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
263 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
267 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
270 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
273 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
279 print $form->buttonsSaveCancel();
287if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
288 if (
$object->fk_soc > 0 && empty($socid)) {
301 if ($action ==
'delete') {
302 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsiteAccount'), $langs->trans(
'ConfirmDeleteWebsiteAccount').
'<br>'.$langs->trans(
'ConfirmDeleteWebsiteAccount2'),
'confirm_delete',
'', 0, 1);
306 $parameters = array(
'formConfirm' => $formconfirm);
307 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
308 if (empty($reshook)) {
309 $formconfirm .= $hookmanager->resPrint;
310 } elseif ($reshook > 0) {
311 $formconfirm = $hookmanager->resPrint;
322 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/website.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToListForThirdParty").
'</a>';
328 $morehtmlref =
'<div class="refidno">';
370 $morehtmlref .=
'</div>';
373 $object->next_prev_filter =
'te.fk_soc:=:'.((int) $socid);
376 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
379 print
'<div class="fichecenter">';
380 print
'<div class="fichehalfleft">';
381 print
'<div class="underbanner clearboth"></div>';
382 print
'<table class="border centpercent tableforfield">'.
"\n";
385 $keyforbreak=
'note_private';
388 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
391 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
397 print
'<div class="clearboth"></div>';
403 if ($action !=
'presend' && $action !=
'editline') {
404 print
'<div class="tabsAction">'.
"\n";
405 $parameters = array();
406 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
411 if (empty($reshook)) {
413 if (empty($user->socid)) {
414 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
418 if ($permissiontoadd) {
419 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->fk_soc) ?
'&socid='.$object->fk_soc :
'').
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
423 if ($permissiontoadd) {
424 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->fk_soc) ?
'&socid='.$object->fk_soc :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
429 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, $params);
436 if (
GETPOST(
'modelselected')) {
440 if ($action !=
'presend') {
441 print
'<div class="fichecenter"><div class="fichehalfleft">';
442 print
'<a name="builddoc"></a>';
444 print
'</div><div class="fichehalfright">';
457 print
'</div></div>';
461 $modelmail =
'websiteaccount';
462 $defaulttopic =
'Information';
463 $diroutput =
isModEnabled(
'website') ? $conf->website->dir_output :
'';
464 $trackid =
'websiteaccount'.$object->id;
466 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class for SocieteAccount.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
websiteaccountPrepareHead($object)
Prepare array of tabs for SocieteAccount.