33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societeaccount.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
42 $langs->loadLangs(array(
"companies",
"website"));
46 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
47 $show_files =
GETPOST(
'show_files',
'int');
48 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
49 $backtopage =
GETPOST(
'backtopage',
'alpha');
50 $optioncss =
GETPOST(
'optioncss',
'aZ');
55 $socid = $user->socid;
59 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
60 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63 if (empty($page) || $page == -1) {
66 $offset = $limit * $page;
67 $pageprev = $page - 1;
68 $pagenext = $page + 1;
70 $sortfield =
't.login';
80 $diroutputmassaction = $conf->website->dir_output.
'/temp/massgeneration/'.$user->id;
81 $hookmanager->initHooks(array(
'websitethirdpartylist'));
84 $extrafields->fetch_name_optionals_label($objectwebsiteaccount->table_element);
86 $search_array_options = $extrafields->getOptionalsFromPost($objectwebsiteaccount->table_element,
'',
'search_');
88 unset($objectwebsiteaccount->fields[
'fk_soc']);
91 $search_all =
GETPOST(
"search_all",
'alpha');
93 foreach ($objectwebsiteaccount->fields as $key => $val) {
94 if (
GETPOST(
'search_'.$key,
'alpha')) {
95 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
100 $fieldstosearchall = array();
101 foreach ($objectwebsiteaccount->fields as $key => $val) {
102 if (!empty($val[
'searchall'])) {
103 $fieldstosearchall[
't.'.$key] = $val[
'label'];
108 $arrayfields = array();
109 foreach ($objectwebsiteaccount->fields as $key => $val) {
111 if (!empty($val[
'visible'])) {
112 $arrayfields[
't.'.$key] = array(
'label'=>$val[
'label'],
'checked'=>(($val[
'visible'] < 0) ? 0 : 1),
'enabled'=>$val[
'enabled']);
117 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
124 $result = $object->fetch($id);
132 $parameters = array(
'id'=>$socid);
133 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
138 if (empty($reshook)) {
140 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage)) {
141 header(
"Location: ".$backtopage);
146 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
149 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
150 foreach ($objectwebsiteaccount->fields as $key => $val) {
154 $search_array_options = array();
156 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
157 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
162 $objectclass =
'WebsiteAccount';
163 $objectlabel =
'WebsiteAccount';
164 $permissiontoread = $user->hasRight(
'societe',
'lire');
165 $permissiontodelete = $user->hasRight(
'societe',
'supprimer');
166 $uploaddir = $conf->societe->multidir_output[$object->entity];
167 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
176 $contactstatic =
new Contact($db);
180 $langs->load(
"companies");
182 $title = $langs->trans(
"WebsiteAccounts");
186 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
187 $param .=
'&contextpage='.urlencode($contextpage);
190 $param .=
'&id='.urlencode($id);
192 if ($limit > 0 && $limit != $conf->liste_limit) {
193 $param .=
'&limit='.urlencode($limit);
195 foreach ($search as $key => $val) {
196 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
198 if ($optioncss !=
'') {
199 $param .=
'&optioncss='.urlencode($optioncss);
202 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
206 print
dol_get_fiche_head($head,
'website', $langs->trans(
"ThirdParty"), - 1,
'company');
208 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
210 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
212 print
'<div class="fichecenter">';
214 print
'<div class="underbanner clearboth"></div>';
216 print
'<table class="border centpercent">';
219 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
220 print
'<tr><td class="titlefield">'.$langs->trans(
'Prefix').
'</td><td colspan="3">'.$object->prefix_comm.
'</td></tr>';
223 if ($object->client) {
224 print
'<tr><td class="titlefield">';
225 print $langs->trans(
'CustomerCode').
'</td><td colspan="3">';
226 print $object->code_client;
227 $tmpcheck = $object->check_codeclient();
228 if ($tmpcheck != 0 && $tmpcheck != -5) {
229 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
234 if ($object->fournisseur) {
235 print
'<tr><td class="titlefield">';
236 print $langs->trans(
'SupplierCode').
'</td><td colspan="3">';
237 print $object->code_fournisseur;
238 $tmpcheck = $object->check_codefournisseur();
239 if ($tmpcheck != 0 && $tmpcheck != -5) {
240 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
253 if ($user->hasRight(
'societe',
'lire')) {
254 $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));
256 $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);
267 foreach ($objectwebsiteaccount->fields as $key => $val) {
268 $sql .=
"t.".$key.
", ";
271 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
272 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
273 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
" as options_".$key.
', ' :
'');
277 $parameters = array();
278 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $objectwebsiteaccount);
279 $sql .= $hookmanager->resPrint;
280 $sql = preg_replace(
'/, $/',
'', $sql);
281 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_account as t";
282 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
283 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
285 if ($objectwebsiteaccount->ismultientitymanaged == 1) {
286 $sql .=
" WHERE t.entity IN (".getEntity(
'societeaccount').
")";
288 $sql .=
" WHERE 1 = 1";
290 $sql .=
" AND fk_soc = ".((int) $object->id);
291 foreach ($search as $key => $val) {
292 $mode_search = (($objectwebsiteaccount->isInt($objectwebsiteaccount->fields[$key]) || $objectwebsiteaccount->isFloat($objectwebsiteaccount->fields[$key])) ? 1 : 0);
293 if ($search[$key] !=
'') {
294 $sql .=
natural_search($key, $search[$key], (($key ==
'status') ? 2 : $mode_search));
298 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
301 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
303 $parameters = array();
304 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $objectwebsiteaccount);
305 $sql .= $hookmanager->resPrint;
322 $sql .= $db->order($sortfield, $sortorder);
326 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
327 $result = $db->query($sql);
335 $sql .= $db->plimit($limit + 1, $offset);
337 $resql = $db->query($sql);
343 $num = $db->num_rows(
$resql);
345 $arrayofselected = is_array($toselect) ? $toselect : array();
348 $arrayofmassactions = array(
352 if ($user->rights->mymodule->delete) {
353 $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
355 if (in_array($massaction, array(
'presend',
'predelete'))) {
356 $arrayofmassactions = array();
358 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
360 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
361 if ($optioncss !=
'') {
362 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
364 print
'<input type="hidden" name="token" value="'.newToken().
'">';
365 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
366 print
'<input type="hidden" name="action" value="list">';
367 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
368 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
369 print
'<input type="hidden" name="page" value="'.$page.
'">';
370 print
'<input type="hidden" name="id" value="'.$id.
'">';
371 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
373 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'', 0, $newcardbutton,
'', $limit);
375 $topicmail =
"Information";
376 $modelmail =
"societeaccount";
378 $trackid =
'thi'.$object->id;
379 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
392 $parameters = array();
393 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $objectwebsiteaccount);
394 if (empty($reshook)) {
395 $moreforfilter .= $hookmanager->resPrint;
397 $moreforfilter = $hookmanager->resPrint;
400 if (!empty($moreforfilter)) {
401 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
402 print $moreforfilter;
406 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
407 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
408 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
410 print
'<div class="div-table-responsive">';
411 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
416 print
'<tr class="liste_titre">';
417 foreach ($objectwebsiteaccount->fields as $key => $val) {
419 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
422 if (in_array($val[
'type'], array(
'timestamp'))) {
425 if ($key ==
'status') {
426 $align .= ($align ?
' ' :
'').
'center';
428 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
429 print
'<td class="liste_titre'.($align ?
' '.$align :
'').
'"><input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag($search[$key]).
'"></td>';
433 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
435 $parameters = array(
'arrayfields'=>$arrayfields);
436 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $objectwebsiteaccount);
437 print $hookmanager->resPrint;
439 print
'<td class="liste_titre maxwidthsearch">';
440 $searchpicto =
$form->showFilterButtons();
448 print
'<tr class="liste_titre">';
449 foreach ($objectwebsiteaccount->fields as $key => $val) {
451 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
454 if (in_array($val[
'type'], array(
'timestamp'))) {
457 if ($key ==
'status') {
458 $align .= ($align ?
' ' :
'').
'center';
460 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
461 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($align ?
'class="'.$align.
'"' :
''), $sortfield, $sortorder, $align.
' ').
"\n";
466 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
468 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
469 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $objectwebsiteaccount);
470 print $hookmanager->resPrint;
471 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ').
"\n";
476 $needToFetchEachLine = 0;
477 if (isset($extrafields->attributes[$object->table_element][
'computed']) && is_array($extrafields->attributes[$object->table_element][
'computed']) && count($extrafields->attributes[$object->table_element][
'computed']) > 0) {
478 foreach ($extrafields->attributes[$object->table_element][
'computed'] as $key => $val) {
479 if (preg_match(
'/\$object/', $val)) {
480 $needToFetchEachLine++;
488 $totalarray = array();
489 while ($i < min($num, $limit)) {
490 $obj = $db->fetch_object(
$resql);
496 $objectwebsiteaccount->id = $obj->rowid;
497 $objectwebsiteaccount->login = $obj->login;
498 $objectwebsiteaccount->ref = $obj->login;
499 foreach ($objectwebsiteaccount->fields as $key => $val) {
500 if (property_exists($objectwebsiteaccount, $key)) {
501 $objectwebsiteaccount->$key = $obj->$key;
506 print
'<tr class="oddeven">';
507 foreach ($objectwebsiteaccount->fields as $key => $val) {
509 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
512 if (in_array($val[
'type'], array(
'timestamp'))) {
515 if ($key ==
'status') {
516 $align .= ($align ?
' ' :
'').
'center';
518 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
521 print
' class="'.$align.
'"';
524 if ($key ==
'login') {
525 print $objectwebsiteaccount->getNomUrl(1,
'', 0,
'', 1);
527 print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key,
'');
531 $totalarray[
'nbfield']++;
533 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
535 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
537 if (!isset($totalarray[
'val'])) {
538 $totalarray[
'val'] = array();
540 if (!isset($totalarray[
'val'][
't.'.$key])) {
541 $totalarray[
'val'][
't.'.$key] = 0;
543 $totalarray[
'val'][
't.'.$key] += $objectwebsiteaccount->$key;
548 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
550 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
551 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objectwebsiteaccount);
552 print $hookmanager->resPrint;
554 print
'<td class="nowrap center">';
555 if ($massactionbutton || $massaction) {
557 if (in_array($obj->rowid, $arrayofselected)) {
560 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
564 $totalarray[
'nbfield']++;
573 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
579 foreach ($arrayfields as $key => $val) {
580 if (!empty($val[
'checked'])) {
584 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
590 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
591 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $objectwebsiteaccount);
592 print $hookmanager->resPrint;
594 print
'</table>'.
"\n";
597 print
'</form>'.
"\n";
600 $hidegeneratedfilelistifempty = 1;
601 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
602 $hidegeneratedfilelistifempty = 0;
605 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
609 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
610 $urlsource .= str_replace(
'&',
'&', $param);
612 $filedir = $diroutputmassaction;
613 $genallowed = $user->rights->mymodule->read;
614 $delallowed = $user->rights->mymodule->create;
616 print $formfile->showdocuments(
'massfilesarea_mymodule',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class for SocieteAccount.
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_get_fiche_end($notab=0)
Return tab footer of a card.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.