dolibarr  13.0.2
websiteaccount_card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
24 // Load Dolibarr environment
25 require '../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array("website", "other"));
33 
34 // Get parameters
35 $id = GETPOST('id', 'int');
36 $ref = GETPOST('ref', 'alpha');
37 $action = GETPOST('action', 'aZ09');
38 $confirm = GETPOST('confirm', 'alpha');
39 $cancel = GETPOST('cancel', 'aZ09');
40 $backtopage = GETPOST('backtopage', 'alpha');
41 
42 // Initialize technical objects
43 $object = new SocieteAccount($db);
44 $extrafields = new ExtraFields($db);
45 $diroutputmassaction = $conf->website->dir_output.'/temp/massgeneration/'.$user->id;
46 $hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array
47 
48 // Fetch optionals attributes and labels
49 $extrafields->fetch_name_optionals_label($object->table_element);
50 
51 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
52 
53 // Initialize array of search criterias
54 $search_all = GETPOST("search_all", 'alpha');
55 $search = array();
56 foreach ($object->fields as $key => $val)
57 {
58  if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
59 }
60 
61 if (empty($action) && empty($id) && empty($ref)) $action = 'view';
62 
63 // Security check - Protection if external user
64 //if ($user->socid > 0) accessforbidden();
65 //if ($user->socid > 0) $socid = $user->socid;
66 //$result = restrictedArea($user, 'website', $id);
67 
68 $permissionnote = $user->rights->websiteaccount->write; // Used by the include of actions_setnotes.inc.php
69 $permissiondellink = $user->rights->websiteaccount->write; // Used by the include of actions_dellink.inc.php
70 $permissiontoadd = $user->rights->websiteaccount->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
71 
72 // Load object
73 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
74 
75 
76 
77 /*
78  * Actions
79  */
80 
81 $parameters = array();
82 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
83 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
84 
85 if (empty($reshook))
86 {
87  $error = 0;
88 
89  $permissiontoadd = $user->rights->website->write;
90  $permissiontodelete = $user->rights->website->delete;
91  $backurlforlist = dol_buildpath('/website/websiteaccount_list.php', 1);
92 
93  // Actions cancel, add, update or delete
94  include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
95 
96  // Actions when printing a doc from card
97  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
98 
99  // Actions to send emails
100  $triggersendname = 'WEBSITEACCOUNT_SENTBYMAIL';
101  $autocopy = 'MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO';
102  $trackid = 'websiteaccount'.$object->id;
103  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
104 }
105 
106 
107 /*
108  * View
109  */
110 
111 $form = new Form($db);
112 $formfile = new FormFile($db);
113 
114 llxHeader('', 'WebsiteAccount', '');
115 
116 // Example : Adding jquery code
117 print '<script type="text/javascript" language="javascript">
118 jQuery(document).ready(function() {
119  function init_myfunc()
120  {
121  jQuery("#myid").removeAttr(\'disabled\');
122  jQuery("#myid").attr(\'disabled\',\'disabled\');
123  }
124  init_myfunc();
125  jQuery("#mybutton").click(function() {
126  init_myfunc();
127  });
128 });
129 </script>';
130 
131 
132 // Part to create
133 if ($action == 'create')
134 {
135  print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("WebsiteAccount")));
136 
137  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
138  print '<input type="hidden" name="token" value="'.newToken().'">';
139  print '<input type="hidden" name="action" value="add">';
140  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
141 
143 
144  print '<table class="border centpercent">'."\n";
145 
146  // Common attributes
147  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
148 
149  // Other attributes
150  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
151 
152  print '</table>'."\n";
153 
155 
156  print '<div class="center">';
157  print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
158  print '&nbsp; ';
159  print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage
160  print '</div>';
161 
162  print '</form>';
163 }
164 
165 // Part to edit record
166 if (($id || $ref) && $action == 'edit')
167 {
168  print load_fiche_titre($langs->trans("WebsiteAccount"));
169 
170  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
171  print '<input type="hidden" name="action" value="update">';
172  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
173  print '<input type="hidden" name="id" value="'.$object->id.'">';
174 
176 
177  print '<table class="border centpercent">'."\n";
178 
179  // Common attributes
180  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
181 
182  // Other attributes
183  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
184 
185  print '</table>';
186 
188 
189  print '<div class="center"><input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
190  print ' &nbsp; <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
191  print '</div>';
192 
193  print '</form>';
194 }
195 
196 // Part to show record
197 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
198 {
199  if ($object->fk_soc > 0 && empty($socid)) $socid = $object->fk_soc;
200 
201  $res = $object->fetch_optionals();
202 
203  $head = websiteaccountPrepareHead($object);
204  print dol_get_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website');
205 
206  $formconfirm = '';
207 
208  // Confirmation to delete
209  if ($action == 'delete') {
210  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteWebsiteAccount'), $langs->trans('ConfirmDeleteWebsiteAccount'), 'confirm_delete', '', 0, 1);
211  }
212 
213  // Call Hook formConfirm
214  $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
215  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
216  if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
217  elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
218 
219  // Print form confirm
220  print $formconfirm;
221 
222 
223  // Object card
224  // ------------------------------------------------------------
225  $linkback = '';
226  if ($socid) $linkback = '<a href="'.DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToListForThirdParty").'</a>';
227  if ($fk_website) $linkback = '<a href="'.DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
228 
229  $morehtmlref = '<div class="refidno">';
230  /*
231  // Ref bis
232  $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', 0, 1);
233  $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->website->creer, 'string', '', null, null, '', 1);
234  // Thirdparty
235  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
236  // Project
237  if (! empty($conf->projet->enabled))
238  {
239  $langs->load("projects");
240  $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
241  if ($user->rights->website->creer)
242  {
243  if ($action != 'classify')
244  {
245  $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
246  if ($action == 'classify') {
247  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
248  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
249  $morehtmlref.='<input type="hidden" name="action" value="classin">';
250  $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
251  $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
252  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
253  $morehtmlref.='</form>';
254  } else {
255  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
256  }
257  }
258  } else {
259  if (! empty($object->fk_project)) {
260  $proj = new Project($db);
261  $proj->fetch($object->fk_project);
262  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
263  $morehtmlref.=$proj->ref;
264  $morehtmlref.='</a>';
265  } else {
266  $morehtmlref.='';
267  }
268  }
269  }
270  */
271  $morehtmlref .= '</div>';
272 
273  if ($socid > 0) $object->next_prev_filter = 'te.fk_soc = '.$socid;
274 
275  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
276 
277 
278  print '<div class="fichecenter">';
279  print '<div class="fichehalfleft">';
280  print '<div class="underbanner clearboth"></div>';
281  print '<table class="border centpercent">'."\n";
282 
283  // Common attributes
284  include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
285 
286  // Other attributes
287  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
288 
289  print '</table>';
290  print '</div>';
291  print '</div>';
292  print '</div>';
293 
294  print '<div class="clearboth"></div><br>';
295 
297 
298 
299  // Buttons for actions
300  if ($action != 'presend' && $action != 'editline') {
301  print '<div class="tabsAction">'."\n";
302  $parameters = array();
303  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
304  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
305 
306  if (empty($reshook))
307  {
308  // Send
309  if (empty($user->socid)) {
310  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>'."\n";
311  }
312 
313  if ($user->rights->website->write)
314  {
315  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
316  }
317 
318  /*
319  if ($user->rights->sellyoursaas->create)
320  {
321  if ($object->status == 1)
322  {
323  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=disable">'.$langs->trans("Disable").'</a></div>'."\n";
324  }
325  else
326  {
327  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=enable">'.$langs->trans("Enable").'</a></div>'."\n";
328  }
329  }
330  */
331 
332  if ($user->rights->website->delete)
333  {
334  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a></div>'."\n";
335  }
336  }
337  print '</div>'."\n";
338  }
339 
340 
341  // Select mail models is same action as presend
342  if (GETPOST('modelselected')) {
343  $action = 'presend';
344  }
345 
346  if ($action != 'presend')
347  {
348  print '<div class="fichecenter"><div class="fichehalfleft">';
349  print '<a name="builddoc"></a>'; // ancre
350 
351  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
352 
353  /*
354  $MAXEVENT = 10;
355 
356  // List of actions on element
357  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
358  $formactions = new FormActions($db);
359  $somethingshown = $formactions->showactions($object, 'websiteaccount', $socid, 1, '', $MAXEVENT);
360  */
361 
362  print '</div></div></div>';
363  }
364 
365  // Presend form
366  $modelmail = 'websiteaccount';
367  $defaulttopic = 'Information';
368  $diroutput = $conf->website->dir_output;
369  $trackid = 'websiteaccount'.$object->id;
370 
371  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
372 }
373 
374 // End of page
375 llxFooter();
376 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
websiteaccountPrepareHead($object)
Prepare array of tabs for SocieteAccount.
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
Class for SocieteAccount.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to offer components to list and upload files.
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.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Definition: categories.php:101
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...