26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/website/lib/websiteaccount.lib.php';
33$langs->loadLangs(array(
"website",
"other"));
38$action =
GETPOST(
'action',
'aZ09');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$cancel =
GETPOST(
'cancel',
'aZ09');
41$backtopage =
GETPOST(
'backtopage',
'alpha');
46$hookmanager->initHooks(array(
$object->element.
'card',
'globalcard'));
49$extrafields->fetch_name_optionals_label(
$object->table_element);
51$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
54$search_all =
GETPOST(
"search_all",
'alpha');
56foreach (
$object->fields as $key => $val) {
57 if (
GETPOST(
'search_'.$key,
'alpha')) {
58 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
62if (empty($action) && empty($id) && empty($ref)) {
67include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
73$permissiontoaccess = (isModEnabled(
'website') && $user->hasRight(
'website',
'read')) || isModEnabled(
'webportal');
74if (!$permissiontoaccess) {
79$permissiontocreate = 0;
80$permissiontodelete = 0;
83 if (
$object->site ==
'dolibarr_website') {
84 $permissiontocreate = isModEnabled(
'website') && $user->hasRight(
'website',
'write');
85 $permissiontodelete = isModEnabled(
'website') && $user->hasRight(
'website',
'delete');
86 } elseif (
$object->site ==
'dolibarr_portal') {
87 $permissiontocreate = isModEnabled(
'webportal') && $user->hasRight(
'webportal',
'write');
90 $permissiontocreate = isModEnabled(
'website') && $user->hasRight(
'website',
'write') || isModEnabled(
'webportal') && $user->hasRight(
'webportal',
'write');
92$permissionnote = $permissiontocreate;
93$permissiondellink = $permissiontocreate;
94$permissiontoadd = $permissiontocreate;
98if (!empty($action) && $action !=
'view') {
99 if (!empty(
$object->fields[
'site'][
'arrayofkeyval'])) {
100 if (isset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_website'])) {
101 if ($action ==
'delete' || $action ==
'confirm_delete') {
102 if (!$user->hasRight(
'website',
'delete')) {
103 unset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_website']);
106 if (!$user->hasRight(
'website',
'write')) {
107 unset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_website']);
112 if (isset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_portal'])) {
113 if (!$user->hasRight(
'webportal',
'write')) {
114 unset(
$object->fields[
'site'][
'arrayofkeyval'][
'dolibarr_portal']);
118 if (empty(
$object->fields[
'site'][
'arrayofkeyval'])) {
124 if (!array_key_exists(
$object->site,
$object->fields[
'site'][
'arrayofkeyval'])) {
137$parameters = array();
138$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
143if (empty($reshook)) {
146 if ($action ==
'add' && !
GETPOST(
'site')) {
147 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Website")),
null,
'errors');
152 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
155 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
158 $triggersendname =
'WEBSITEACCOUNT_SENTBYMAIL';
159 $autocopy =
'MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO';
160 $trackid =
'websiteaccount'.$object->id;
161 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
169$form =
new Form($db);
172$title = $langs->trans(
"WebsiteAccount");
179if ($action ==
'create' || $action ==
'edit') {
180 if (!empty(
$object->fields[
'site'][
'visible']) && !empty(
$object->fields[
'fk_website'][
'visible'])) {
181 $site_type_js =
'function siteTypeChange(site_type) {';
182 $site_type_js .=
' if (site_type == "dolibarr_website") {';
183 $site_type_js .=
' jQuery("tr.field_fk_website").show();';
184 $site_type_js .=
' } else {';
185 $site_type_js .=
' jQuery("select#fk_website").val("-1").change();';
186 $site_type_js .=
' jQuery("tr.field_fk_website").hide();';
187 $site_type_js .=
' }';
188 $site_type_js .=
'}';
189 $site_type_js .=
'jQuery(document).ready(function(){';
190 $site_type_js .=
' siteTypeChange(jQuery("#site").val());';
191 $site_type_js .=
' jQuery("#site").change(function(){';
192 $site_type_js .=
' siteTypeChange(this.value);';
193 $site_type_js .=
' });';
194 $site_type_js .=
'});';
196 $out_js .=
'<script type"text/javascript">';
197 $out_js .= $site_type_js;
198 $out_js .=
'</script>';
203if ($action ==
'create') {
204 if (empty($permissiontoadd)) {
208 print
load_fiche_titre($langs->trans(
"NewWebsiteAccount", $langs->transnoentitiesnoconv(
"WebsiteAccount")));
210 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
211 print
'<input type="hidden" name="token" value="'.newToken().
'">';
212 print
'<input type="hidden" name="action" value="add">';
214 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
216 if (!empty($backtopageforcancel)) {
217 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
219 if (!empty($backtopagejsfields)) {
220 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
222 if (!empty($dol_openinpopup)) {
223 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
228 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
231 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
234 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
236 print
'</table>'.
"\n";
240 print $form->buttonsSaveCancel(
"Create");
248if (($id || $ref) && $action ==
'edit') {
251 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
252 print
'<input type="hidden" name="token" value="'.newToken().
'">';
253 print
'<input type="hidden" name="action" value="update">';
254 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
255 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
259 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
262 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
265 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
271 print $form->buttonsSaveCancel();
279if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
280 if (
$object->fk_soc > 0 && empty($socid)) {
293 if ($action ==
'delete') {
294 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsiteAccount'), $langs->trans(
'ConfirmDeleteWebsiteAccount'),
'confirm_delete',
'', 0, 1);
298 $parameters = array(
'formConfirm' => $formconfirm);
299 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
300 if (empty($reshook)) {
301 $formconfirm .= $hookmanager->resPrint;
302 } elseif ($reshook > 0) {
303 $formconfirm = $hookmanager->resPrint;
314 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/website.php?socid='.$socid.
'&restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToListForThirdParty").
'</a>';
320 $morehtmlref =
'<div class="refidno">';
362 $morehtmlref .=
'</div>';
365 $object->next_prev_filter =
'te.fk_soc = '.((int) $socid);
368 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'rowid', $morehtmlref);
371 print
'<div class="fichecenter">';
372 print
'<div class="fichehalfleft">';
373 print
'<div class="underbanner clearboth"></div>';
374 print
'<table class="border centpercent tableforfield">'.
"\n";
377 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
380 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
386 print
'<div class="clearboth"></div>';
392 if ($action !=
'presend' && $action !=
'editline') {
393 print
'<div class="tabsAction">'.
"\n";
394 $parameters = array();
395 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
400 if (empty($reshook)) {
402 if (empty($user->socid)) {
403 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
407 if ($permissiontoadd) {
408 print
dolGetButtonAction(
'', $langs->trans(
'ToClone'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.(!empty(
$object->socid) ?
'&socid='.$object->socid :
'').
'&action=clone&token='.
newToken(),
'', $permissiontoadd);
413 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, $params);
420 if (
GETPOST(
'modelselected')) {
424 if ($action !=
'presend') {
425 print
'<div class="fichecenter"><div class="fichehalfleft">';
426 print
'<a name="builddoc"></a>';
428 print
'</div><div class="fichehalfright">';
441 print
'</div></div>';
445 $modelmail =
'websiteaccount';
446 $defaulttopic =
'Information';
447 $diroutput = isModEnabled(
'website') ? $conf->website->dir_output :
'';
448 $trackid =
'websiteaccount'.$object->id;
450 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class for SocieteAccount.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.