31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
38 $langs->loadLangs(array(
"companies",
"website"));
40 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
41 $show_files =
GETPOST(
'show_files',
'int');
42 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
43 $backtopage =
GETPOST(
'backtopage',
'alpha');
44 $optioncss =
GETPOST(
'optioncss',
'aZ');
46 $search_status =
GETPOST(
'search_status');
50 if ($user->socid) $socid = $user->socid;
53 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
54 $sortfield =
GETPOST(
"sortfield",
'alpha');
55 $sortorder =
GETPOST(
"sortorder",
'alpha');
57 if (empty($page) || $page == -1) { $page = 0; }
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
61 if (!$sortfield) $sortfield =
't.login';
62 if (!$sortorder) $sortorder =
'ASC';
68 $diroutputmassaction = $conf->website->dir_output.
'/temp/massgeneration/'.$user->id;
69 $hookmanager->initHooks(array(
'websitethirdpartylist'));
72 $extrafields->fetch_name_optionals_label($objectwebsiteaccount->table_element);
74 $search_array_options = $extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element,
'',
'search_');
76 unset($objectwebsiteaccount->fields[
'fk_soc']);
79 $search_all =
GETPOST(
"search_all",
'alpha');
81 foreach ($objectwebsiteaccount->fields as $key => $val)
83 if (
GETPOST(
'search_'.$key,
'alpha')) $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
87 $fieldstosearchall = array();
88 foreach ($objectwebsiteaccount->fields as $key => $val)
90 if ($val[
'searchall']) $fieldstosearchall[
't.'.$key] = $val[
'label'];
94 $arrayfields = array();
95 foreach ($objectwebsiteaccount->fields as $key => $val)
98 if (!empty($val[
'visible'])) $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled']);
102 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
110 $result = $object->fetch($id);
118 $parameters = array(
'id'=>$socid);
119 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
120 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
125 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage))
127 header(
"Location: ".$backtopage);
132 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
135 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
137 foreach ($objectwebsiteaccount->fields as $key => $val)
142 $search_array_options = array();
144 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
145 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha'))
151 $objectclass =
'WebsiteAccount';
152 $objectlabel =
'WebsiteAccount';
153 $permissiontoread = $user->rights->societe->lire;
154 $permissiontodelete = $user->rights->societe->supprimer;
155 $uploaddir = $conf->societe->dir_output;
156 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
165 $contactstatic =
new Contact($db);
167 $form =
new Form($db);
169 $langs->load(
"companies");
171 $title = $langs->trans(
"WebsiteAccounts");
175 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
176 if ($id > 0) $param .=
'&id='.urlencode($id);
177 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
178 foreach ($search as $key => $val)
180 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
182 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
184 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
190 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
192 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
194 print '<div class="fichecenter">';
196 print '<div class="underbanner clearboth"></div>';
198 print '<table class="border centpercent">';
201 if (!empty($conf->global->SOCIETE_USEPREFIX))
203 print '<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
206 if ($object->client) {
207 print '<tr><td class="titlefield">';
208 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
209 print $object->code_client;
210 $tmpcheck = $object->check_codeclient();
211 if ($tmpcheck != 0 && $tmpcheck != -5) {
212 print ' <font class="error">('.$langs->trans(
"WrongCustomerCode").
')</font>';
217 if ($object->fournisseur) {
218 print '<tr><td class="titlefield">';
219 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
220 print $object->code_fournisseur;
221 $tmpcheck = $object->check_codefournisseur();
222 if ($tmpcheck != 0 && $tmpcheck != -5) {
223 print ' <font class="error">('.$langs->trans(
"WrongSupplierCode").
')</font>';
235 if (!empty($conf->website->enabled)) {
236 if (!empty($user->rights->societe->lire)) {
237 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddWebsiteAccount"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id));
239 $newcardbutton .=
dolGetButtonTitle($langs->trans(
"AddAction"),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/website/websiteaccount_card.php?action=create&fk_soc='.$object->id.
'&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id),
'', 0);
250 foreach ($objectwebsiteaccount->fields as $key => $val)
252 $sql .=
't.'.$key.
', ';
255 if (!empty($extrafields->attributes[$object->table_element][
'label']))
256 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
' as options_'.$key.
', ' :
'');
258 $parameters = array();
259 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $objectwebsiteaccount);
260 $sql .= $hookmanager->resPrint;
261 $sql = preg_replace(
'/, $/',
'', $sql);
262 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as t";
263 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
264 if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql .=
" WHERE t.entity IN (".getEntity(
'societeaccount').
")";
265 else $sql .=
" WHERE 1 = 1";
266 $sql .=
" AND fk_soc = ".$object->id;
267 foreach ($search as $key => $val)
269 $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
270 if ($search[$key] !=
'') $sql .=
natural_search($key, $search[$key], (($key ==
'status') ? 2 : $mode_search));
272 if ($search_all) $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
274 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
276 $parameters = array();
277 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $objectwebsiteaccount);
278 $sql .= $hookmanager->resPrint;
295 $sql .= $db->order($sortfield, $sortorder);
298 $nbtotalofrecords =
'';
299 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
301 $result = $db->query($sql);
302 $nbtotalofrecords = $db->num_rows($result);
303 if (($page * $limit) > $nbtotalofrecords)
310 $sql .= $db->plimit($limit + 1, $offset);
312 $resql = $db->query($sql);
319 $num = $db->num_rows(
$resql);
321 $arrayofselected = is_array($toselect) ? $toselect : array();
324 $arrayofmassactions = array(
328 if ($user->rights->mymodule->delete) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
329 if (in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
330 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
332 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
333 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
334 print '<input type="hidden" name="token" value="'.newToken().
'">';
335 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
336 print '<input type="hidden" name="action" value="list">';
337 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
338 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
339 print '<input type="hidden" name="page" value="'.$page.
'">';
340 print '<input type="hidden" name="id" value="'.$id.
'">';
341 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
343 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'', 0, $newcardbutton,
'', $limit);
345 $topicmail =
"Information";
346 $modelmail =
"societeaccount";
348 $trackid =
'thi'.$object->id;
349 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
362 $parameters = array();
363 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $objectwebsiteaccount);
364 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
365 else $moreforfilter = $hookmanager->resPrint;
367 if (!empty($moreforfilter))
369 print '<div class="liste_titre liste_titre_bydiv centpercent">';
370 print $moreforfilter;
374 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
375 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
376 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
378 print '<div class="div-table-responsive">';
379 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
384 print '<tr class="liste_titre">';
385 foreach ($objectwebsiteaccount->fields as $key => $val)
388 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $align =
'center';
389 if (in_array($val[
'type'], array(
'timestamp'))) $align .=
' nowrap';
390 if ($key ==
'status') $align .= ($align ?
' ' :
'').
'center';
391 if (!empty($arrayfields[
't.'.$key][
'checked'])) print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'"><input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag($search[$key]).
'"></td>';
394 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
396 $parameters = array(
'arrayfields'=>$arrayfields);
397 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $objectwebsiteaccount);
398 print $hookmanager->resPrint;
400 print
'<td class="liste_titre maxwidthsearch">';
401 $searchpicto = $form->showFilterButtons();
409 print
'<tr class="liste_titre">';
410 foreach ($objectwebsiteaccount->fields as $key => $val)
413 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $align =
'center';
414 if (in_array($val[
'type'], array(
'timestamp'))) $align .=
'nowrap';
415 if ($key ==
'status') $align .= ($align ?
' ' :
'').
'center';
416 if (!empty($arrayfields[
't.'.$key][
'checked'])) print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0,
$_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
420 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
422 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
423 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $objectwebsiteaccount);
424 print $hookmanager->resPrint;
425 print
getTitleFieldOfList($selectedfields, 0,
$_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
430 $needToFetchEachLine = 0;
431 if (is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0)
433 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val)
435 if (preg_match(
'/\$object/', $val)) $needToFetchEachLine++;
442 $totalarray = array();
443 while ($i < min($num, $limit))
445 $obj = $db->fetch_object(
$resql);
446 if (empty($obj))
break;
449 $objectwebsiteaccount->id = $obj->rowid;
450 $objectwebsiteaccount->login = $obj->login;
451 $objectwebsiteaccount->ref = $obj->login;
452 foreach ($objectwebsiteaccount->fields as $key => $val)
454 if (property_exists($obj, $key)) $object->$key = $obj->$key;
458 print
'<tr class="oddeven">';
459 foreach ($objectwebsiteaccount->fields as $key => $val)
462 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) $align =
'center';
463 if (in_array($val[
'type'], array(
'timestamp'))) $align .=
'nowrap';
464 if ($key ==
'status') $align .= ($align ?
' ' :
'').
'center';
465 if (!empty($arrayfields[
't.'.$key][
'checked']))
468 if ($align) print
' class="'.$align.
'"';
470 if ($key ==
'login') print $objectwebsiteaccount->getNomUrl(1,
'', 0,
'', 1);
471 else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key,
'');
473 if (!$i) $totalarray[
'nbfield']++;
474 if (!empty($val[
'isameasure']))
476 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
477 $totalarray[
'val'][
't.'.$key] += $obj->$key;
482 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
484 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
485 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objectwebsiteaccount);
486 print $hookmanager->resPrint;
488 print
'<td class="nowrap center">';
489 if ($massactionbutton || $massaction)
492 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
493 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
496 if (!$i) $totalarray[
'nbfield']++;
504 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
511 foreach ($arrayfields as $key => $val) {
if (!empty($val[
'checked'])) $colspan++; }
512 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
518 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
519 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $objectwebsiteaccount);
520 print $hookmanager->resPrint;
522 print
'</table>'.
"\n";
525 print
'</form>'.
"\n";
527 if (in_array(
'builddoc', $arrayofmassactions) && ($nbtotalofrecords ===
'' || $nbtotalofrecords))
529 $hidegeneratedfilelistifempty = 1;
530 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
532 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
536 $urlsource =
$_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
537 $urlsource .= str_replace(
'&',
'&', $param);
539 $filedir = $diroutputmassaction;
540 $genallowed = $user->rights->mymodule->read;
541 $delallowed = $user->rights->mymodule->create;
543 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
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.
Class for SocieteAccount.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
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_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...