diff --git a/build/phpstan/bootstrap.php b/build/phpstan/bootstrap.php index e567b609a2f..6b6fd7b292e 100644 --- a/build/phpstan/bootstrap.php +++ b/build/phpstan/bootstrap.php @@ -8,7 +8,7 @@ define('DOL_DOCUMENT_ROOT', __DIR__ . '/../../htdocs'); define('DOL_DATA_ROOT', __DIR__ . '/../../documents'); define('DOL_URL_ROOT', '/'); -// Load the main.inc.php file to have finctions llx_Header and llx_Footer defined +// Load the main.inc.php file to have functions llx_Header and llx_Footer defined if (! defined("NOLOGIN")) define("NOLOGIN", '1'); global $conf, $langs, $user, $db; include_once __DIR__ . '/../../htdocs/main.inc.php'; diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index b59d924212a..88ad415a64c 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2007-2011 Laurent Destailleur + * Copyright (C) 2007-2019 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,12 +58,12 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $ret=$object->fetch($id); if ($ret > 0) { - $outname=$object->name; - $outlabel = ''; + $outref = $object->ref; + $outname = $object->name; $outdesc = ''; $outtype = $object->type; - $outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype); + $outjson = array('ref' => $outref, 'name' => $outname, 'desc' => $outdesc, 'type' => $outtype); } echo json_encode($outjson); diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php index 27aeca883cc..7b8895a1f3f 100644 --- a/htdocs/societe/canvas/company/actions_card_company.class.php +++ b/htdocs/societe/canvas/company/actions_card_company.class.php @@ -23,9 +23,11 @@ */ include_once DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php'; + /** - * \class ActionsCardCompany - * \brief Class with controller methods for thirdparty canvas + * ActionsCardCompany + * + * Class with controller methods for thirdparty canvas */ class ActionsCardCompany extends ActionsCardCommon { diff --git a/htdocs/societe/canvas/individual/actions_card_individual.class.php b/htdocs/societe/canvas/individual/actions_card_individual.class.php index 391fd85c836..cf6118fd023 100644 --- a/htdocs/societe/canvas/individual/actions_card_individual.class.php +++ b/htdocs/societe/canvas/individual/actions_card_individual.class.php @@ -22,9 +22,11 @@ */ include_once DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php'; + /** - * \class ActionsCardIndividual - * \brief Class with controller methods for individual canvas + * ActionsCardIndividual + * + * Class with controller methods for individual canvas */ class ActionsCardIndividual extends ActionsCardCommon { diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3d9f3d7304c..f69b37b262c 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -251,10 +251,10 @@ if (empty($reshook)) // External modules should update their ones too if (! $error) { - $reshook = $hookmanager->executeHooks('replaceThirdparty', array( + $reshook = $hookmanager->executeHooks('replaceThirdparty', array( 'soc_origin' => $soc_origin->id, 'soc_dest' => $object->id - ), $soc_dest, $action); + ), $object, $action); if ($reshook < 0) { @@ -1188,7 +1188,7 @@ else // Prospect/Customer print ''.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).''; print ''; - $selected=(GETPOSTISSET('client', 'int')?GETPOST('client', 'int'):$object->client); + $selected=(GETPOSTISSET('client')?GETPOST('client', 'int'):$object->client); print $formcompany->selectProspectCustomerType($selected); print ''; @@ -2257,7 +2257,6 @@ else if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''.$langs->trans('Prefix').''.$object->prefix_comm.''; - print $htmllogobar; $htmllogobar=''; print ''; } @@ -2269,7 +2268,6 @@ else print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print ''; - print $htmllogobar; $htmllogobar=''; print ''; } @@ -2281,7 +2279,6 @@ else print $object->code_fournisseur; if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print ''; - print $htmllogobar; $htmllogobar=''; print ''; } @@ -2291,9 +2288,6 @@ else print ''; print $langs->trans('Gencod').''.$object->barcode; print ''; - if ($htmllogobar) $htmllogobar.=$form->showbarcode($object); - print $htmllogobar; - $htmllogobar=''; print ''; } diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php index 4275d356566..911d995dd78 100644 --- a/htdocs/societe/class/companypaymentmode.class.php +++ b/htdocs/societe/class/companypaymentmode.class.php @@ -310,7 +310,7 @@ class CompanyPaymentMode extends CommonObject if ($type) $morewhere.= " AND type = '".$this->db->escape($type)."'"; $result = $this->fetchCommon($id, $ref, $morewhere); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); return $result; } diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 5f333da69a3..2ab63178f4c 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -79,7 +79,7 @@ class SocieteAccount extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'default'=>1), - 'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>-1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Key account',), + 'key_account' => array('type'=>'varchar(128)', 'label'=>'KeyAccount', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Key account',), 'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10), 'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>0, 'enabled'=>1, 'position'=>30), 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1), diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index d6df59f4740..4657a3e3f64 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -63,41 +63,6 @@ print load_fiche_titre($transAreaType, $linkback, 'title_companies.png'); print '
'; -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -{ - // Search thirdparty - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) - { - $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); - } - // Search contact/address - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) - { - $listofsearchfields['search_contact']=array('text'=>'Contact'); - } - - if (count($listofsearchfields)) - { - print '
'; - print ''; - print ''; - $i=0; - foreach($listofsearchfields as $key => $value) - { - if ($i == 0) print ''; - print ''; - print ''; - if ($i == 0) print ''; - print ''; - $i++; - } - print '
'.$langs->trans("Search").'
'; - print '
'; - print '
'; - } -} - - /* * Statistics area */ @@ -194,7 +159,7 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS print '
'; print ''; print ''; - print '
'.$langs->trans("Categories").'
'; + print '
'; $sql = "SELECT c.label, count(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 51a7ccb24bb..fdd4f54b6c8 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1208,8 +1208,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print_liste_field_titre("BIC"); if (! empty($conf->prelevement->enabled)) { - print print_liste_field_titre("RUM"); - print print_liste_field_titre("WithdrawMode"); + print_liste_field_titre("RUM"); + print_liste_field_titre("WithdrawMode"); } print_liste_field_titre("DefaultRIB", '', '', '', '', '', '', '', 'center '); print_liste_field_titre('', '', '', '', '', '', '', '', 'center '); diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 72bf7f6d27e..d09861da3f8 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -37,6 +37,18 @@ $langs->loadLangs(array("orders", "companies")); $id=GETPOST('id', 'int')?GETPOST('id', 'int'):GETPOST('socid', 'int'); $ref=GETPOST('ref', 'alpha'); $action=GETPOST('action', 'alpha'); +$massaction=GETPOST('massaction', 'alpha'); + +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield=GETPOST("sortfield", 'alpha'); +$sortorder=GETPOST("sortorder", 'alpha'); +$page=GETPOST("page", 'int'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="s.nom"; +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -233,12 +245,14 @@ if ($id > 0 || ! empty($ref)) { $num = $db->num_rows($resql); - if ($num > 0 ) + if ($num > 0) { + $param = ''; + $titre=$langs->trans("MembersListOfTiers"); print '
'; - print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, ''); print ""; print ''; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index fa868de6e42..fa74b1b3dd3 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -230,9 +230,9 @@ dol_fiche_end(); $newcardbutton = ''; if (! empty($conf->website->enabled)) { if (! empty($user->rights->societe->lire)) { - $morehtmlright.= 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)); + $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)); } else { - $morehtmlright.= 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); + $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); } } @@ -248,14 +248,15 @@ foreach($objectwebsiteaccount->fields as $key => $val) $sql.='t.'.$key.', '; } // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); // Add fields from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/', '', $sql); $sql.= " FROM ".MAIN_DB_PREFIX."societe_account as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_account_extrafields as ef on (t.rowid = ef.fk_object)"; +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)"; if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('societeaccount').")"; else $sql.=" WHERE 1 = 1"; $sql.=" AND fk_soc = ".$object->id; @@ -428,6 +429,16 @@ foreach ($extrafields->attribute_computed as $key => $val) } +// Detect if we need a fetch on each output line +$needToFetchEachLine=0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + // Loop on record // -------------------------------------------------------------------- $i=0; diff --git a/phpstan.neon b/phpstan.neon index 34dd50fb4bc..6d63f931375 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,6 +4,7 @@ parameters: - %currentWorkingDirectory%/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php - %currentWorkingDirectory%/htdocs/includes/* - %currentWorkingDirectory%/htdocs/*/class/api_* + - %currentWorkingDirectory%/htdocs/*/canvas/*/tpl/*.tpl.php autoload_directories: - %currentWorkingDirectory%/htdocs/accountancy/class - %currentWorkingDirectory%/htdocs/adherents/class @@ -23,14 +24,94 @@ parameters: - %currentWorkingDirectory%/htdocs/compta/facture/class - %currentWorkingDirectory%/htdocs/compta/localtax/class - %currentWorkingDirectory%/htdocs/compta/paiement/class + - %currentWorkingDirectory%/htdocs/compta/prelevement/class + - %currentWorkingDirectory%/htdocs/compta/salaries/class + - %currentWorkingDirectory%/htdocs/compta/sociales/class + - %currentWorkingDirectory%/htdocs/compta/tva/class - %currentWorkingDirectory%/htdocs/conf - %currentWorkingDirectory%/htdocs/contact/class - %currentWorkingDirectory%/htdocs/contrat/class - %currentWorkingDirectory%/htdocs/core/class + - %currentWorkingDirectory%/htdocs/core/lib + - %currentWorkingDirectory%/htdocs/core/triggers + - %currentWorkingDirectory%/htdocs/core/modules/bank + - %currentWorkingDirectory%/htdocs/core/modules/bom + - %currentWorkingDirectory%/htdocs/core/modules/commande + - %currentWorkingDirectory%/htdocs/core/modules/expedition + #- %currentWorkingDirectory%/htdocs/core/modules/expensereport + - %currentWorkingDirectory%/htdocs/core/modules/facture + - %currentWorkingDirectory%/htdocs/core/modules/fichinter + - %currentWorkingDirectory%/htdocs/core/modules/holiday + - %currentWorkingDirectory%/htdocs/core/modules/livraison + #- %currentWorkingDirectory%/htdocs/core/modules/member + - %currentWorkingDirectory%/htdocs/core/modules/payment + - %currentWorkingDirectory%/htdocs/core/modules/product + - %currentWorkingDirectory%/htdocs/core/modules/propale + - %currentWorkingDirectory%/htdocs/core/modules/reception + #- %currentWorkingDirectory%/htdocs/core/modules/stock + - %currentWorkingDirectory%/htdocs/core/modules/supplier_invoice + - %currentWorkingDirectory%/htdocs/core/modules/supplier_order + #- %currentWorkingDirectory%/htdocs/core/modules/supplier_payment + - %currentWorkingDirectory%/htdocs/core/modules/supplier_proposal + - %currentWorkingDirectory%/htdocs/cron/class + - %currentWorkingDirectory%/htdocs/datapolicy/class + - %currentWorkingDirectory%/htdocs/debugbar/class + - %currentWorkingDirectory%/htdocs/don/class + - %currentWorkingDirectory%/htdocs/ecm/class + - %currentWorkingDirectory%/htdocs/emailcollector/class + - %currentWorkingDirectory%/htdocs/expedition/class + - %currentWorkingDirectory%/htdocs/expensereport/class + - %currentWorkingDirectory%/htdocs/exports/class + - %currentWorkingDirectory%/htdocs/fichinter/class + - %currentWorkingDirectory%/htdocs/fourn/class + - %currentWorkingDirectory%/htdocs/holiday/class + - %currentWorkingDirectory%/htdocs/hrm/class + - %currentWorkingDirectory%/htdocs/imports/class + - %currentWorkingDirectory%/htdocs/livraison/class + - %currentWorkingDirectory%/htdocs/loan/class + - %currentWorkingDirectory%/htdocs/mailmanspip/class + - %currentWorkingDirectory%/htdocs/multicurrency/class + - %currentWorkingDirectory%/htdocs/opensurvey/class - %currentWorkingDirectory%/htdocs/product/class + - %currentWorkingDirectory%/htdocs/projet/class + - %currentWorkingDirectory%/htdocs/reception/class + - %currentWorkingDirectory%/htdocs/resource/class - %currentWorkingDirectory%/htdocs/societe/class + - %currentWorkingDirectory%/htdocs/stripe/class + - %currentWorkingDirectory%/htdocs/supplier_proposal/class + - %currentWorkingDirectory%/htdocs/ticket/class - %currentWorkingDirectory%/htdocs/user/class - autoload_files: [] + - %currentWorkingDirectory%/htdocs/variants/class + - %currentWorkingDirectory%/htdocs/website/class + autoload_files: + - %currentWorkingDirectory%/build/phpstan/bootstrap.php + - %currentWorkingDirectory%/htdocs/core/lib/accounting.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/admin.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/agenda.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/ajax.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/asset.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/bank.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/barcode.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/categories.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/company.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/contact.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/contract.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/cron.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/date.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/doc.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/doleditor.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/donation.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/ecm.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/emailing.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/expedition.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/expensereport.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/fichinter.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/files.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/fiscalyear.lib.php + #- %currentWorkingDirectory%/htdocs/core/lib/format_cards.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/fourn.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/functions.lib.php + - %currentWorkingDirectory%/htdocs/core/lib/functions2.lib.php featureToggles: subtractableTypes: false validateParameters: false @@ -66,6 +147,9 @@ parameters: - '#Undefined variable: \$db#' - '#Undefined variable: \$conf#' - '#Undefined variable: \$hookmanager#' + - '#Undefined variable: \$mysoc#' + - '#Undefined variable: \$error#' + - '#Undefined variable: \$errors#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512