From 3c6c50935849d28838fd332bccaca99070443d4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2016 10:26:40 +0200 Subject: [PATCH] Fix compatibility with old behaviour (direct open of card after a search) --- htdocs/societe/list.php | 1055 ++++++++++++++++++++------------------- 1 file changed, 530 insertions(+), 525 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 019542810e8..e4e67ba7eab 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -254,9 +254,6 @@ $prospectstatic=new Client($db); $prospectstatic->client=2; $prospectstatic->loadCacheOfProspStatus(); -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('',$langs->trans("ThirdParty"),$help_url); - $title=$langs->trans("ListOfThirdParties"); if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers"); @@ -432,347 +429,567 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); -if ($resql) +if (! $resql) { - $num = $db->num_rows($resql); - $i = 0; + dol_print_error($db); + exit; +} - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall != '') $param .= "&sall=".urlencode($sall); - if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ); - if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); - if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); - if ($search_town != '') $param.= "&search_town=".urlencode($search_town); - if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); - if ($search_state != '') $param.= "&search_state=".urlencode($search_state); - if ($search_country != '') $param.= "&search_country=".urlencode($search_country); - if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); - if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); - if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); - if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); - if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode); - if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); - if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); - if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); - if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); - if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); - if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); - if ($search_country != '') $param.='&search_country='.urlencode($search_country); - if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm; - if ($search_level_from != '') $param.='&search_level_from='.$search_level_from; - if ($search_level_to != '') $param.='&search_level_to='.$search_level_to; - if ($type != '') $param.='&type='.urlencode($type); - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - - // Show delete result message - if (GETPOST('delsoc')) - { - setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); - } +$num = $db->num_rows($resql); +$i = 0; - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/societe/soc.php?socid='.$id); + exit; +} - $langs->load("other"); - $textprofid=array(); - foreach(array(1,2,3,4,5,6) as $key) - { - $label=$langs->transnoentities("ProfId".$key.$mysoc->country_code); - $textprofid[$key]=''; - if ($label != "ProfId".$key.$mysoc->country_code) - { // Get only text between () - if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1]; - $textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label); - } +$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +llxHeader('',$langs->trans("ThirdParty"),$help_url); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($sall != '') $param .= "&sall=".urlencode($sall); +if ($search_categ > 0) $param.='&search_categ='.urlencode($search_categ); +if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); +if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); +if ($search_town != '') $param.= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); +if ($search_state != '') $param.= "&search_state=".urlencode($search_state); +if ($search_country != '') $param.= "&search_country=".urlencode($search_country); +if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); +if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); +if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); +if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); +if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode); +if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); +if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); +if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); +if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); +if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); +if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); +if ($search_country != '') $param.='&search_country='.urlencode($search_country); +if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($search_status != '') $param.='&search_status='.urlencode($search_status); +if ($search_stcomm != '') $param.='&search_stcomm='.$search_stcomm; +if ($search_level_from != '') $param.='&search_level_from='.$search_level_from; +if ($search_level_to != '') $param.='&search_level_to='.$search_level_to; +if ($type != '') $param.='&type='.urlencode($type); +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +// Show delete result message +if (GETPOST('delsoc')) +{ + setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs'); +} + +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); + +$langs->load("other"); +$textprofid=array(); +foreach(array(1,2,3,4,5,6) as $key) +{ + $label=$langs->transnoentities("ProfId".$key.$mysoc->country_code); + $textprofid[$key]=''; + if ($label != "ProfId".$key.$mysoc->country_code) + { // Get only text between () + if (preg_match('/\((.*)\)/i',$label,$reg)) $label=$reg[1]; + $textprofid[$key]=$langs->trans("ProfIdShortDesc",$key,$mysoc->country_code,$label); } +} - if ($search_all) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); - } - - // Filter on categories - $moreforfilter=''; - if ($type == 'c' || $type == 'p') +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); +} + +// Filter on categories +$moreforfilter=''; +if ($type == 'c' || $type == 'p') +{ + if (! empty($conf->categorie->enabled)) { - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories('customer',$search_categ,'search_categ',1); - $moreforfilter.='
'; - } + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ,'search_categ',1); + $moreforfilter.='
'; } - - // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) +} + +// If the user can view prospects other than his' +if ($user->rights->societe->client->voir || $socid) +{ + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; + $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); + $moreforfilter.='
'; +} +if ($type == 'f') +{ + if (! empty($conf->categorie->enabled)) { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user, 0, 1, 'maxwidth300'); + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1); $moreforfilter.='
'; } - if ($type == 'f') - { - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories('supplier',$search_categ,'search_categ',1); - $moreforfilter.='
'; - } - } - if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - $parameters=array('type'=>$type); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print ''; - - print ''; - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($langs->trans("Gencod"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); - if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre(''); // type of customer - if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } - } - // Hook fields - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +} +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + $parameters=array('type'=>$type); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); - print "
\n"; + print ''; +} - // Fields title search - print ''; - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - } +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +print '
'; - if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; - print ''; - print '
'; + +print ''; +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.barcode']['checked'])) print_liste_field_titre($langs->trans("Gencod"), $_SERVER["PHP_SELF"], "s.barcode",$param,'','',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_client']['checked'])) print_liste_field_titre($arrayfields['s.code_client']['label'],$_SERVER["PHP_SELF"],"s.code_client","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'],$_SERVER["PHP_SELF"],"s.code_compta","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'],$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.siren']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId1Short"),$textprofid[1],1,0),$_SERVER["PHP_SELF"],"s.siren","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.siret']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder); +print_liste_field_titre(''); // type of customer +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + +// Fields title search +print ''; +if (! empty($arrayfields['s.nom']['checked'])) +{ + print ''; +} +// Barcode +if (! empty($arrayfields['s.barcode']['checked'])) +{ + print ''; +} +// Customer code +if (! empty($arrayfields['s.code_client']['checked'])) +{ + print ''; +} +// Supplier code +if (! empty($arrayfields['s.code_fournisseur']['checked'])) +{ + print ''; +} +// Account Customer code +if (! empty($arrayfields['s.code_compta']['checked'])) +{ + print ''; +} +// Account Supplier code +if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) +{ + print ''; +} +// Town +if (! empty($arrayfields['s.town']['checked'])) +{ + print ''; +} +// Zip +if (! empty($arrayfields['s.zip']['checked'])) +{ + print ''; +} +// State +if (! empty($arrayfields['state.nom']['checked'])) +{ + print ''; +} +// Country +if (! empty($arrayfields['country.code_iso']['checked'])) +{ + print ''; +} +// Company type +if (! empty($arrayfields['typent.code']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.siren']['checked'])) +{ + // IdProf1 + print ''; +} +if (! empty($arrayfields['s.siret']['checked'])) +{ + // IdProf2 + print ''; +} +if (! empty($arrayfields['s.ape']['checked'])) +{ + // IdProf3 + print ''; +} +if (! empty($arrayfields['s.idprof4']['checked'])) +{ + // IdProf4 + print ''; +} +if (! empty($arrayfields['s.idprof5']['checked'])) +{ + // IdProf5 + print ''; +} +if (! empty($arrayfields['s.idprof6']['checked'])) +{ + // IdProf6 + print ''; +} + +// Type (customer/prospect/supplier) +print ''; + +if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) +{ + // Prospect level + print ''; +} + +if (! empty($arrayfields['s.fk_stcomm']['checked'])) +{ + // Prospect status + print ''; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (! empty($arrayfields['s.datec']['checked'])) +{ + print ''; +} +// Date modification +if (! empty($arrayfields['s.tms']['checked'])) +{ + print ''; +} +// Status +if (! empty($arrayfields['s.status']['checked'])) +{ + print ''; +} +// Action column +print ''; + +print "\n"; + +$var=True; + +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + $var=!$var; + + $companystatic->id=$obj->rowid; + $companystatic->name=$obj->name; + $companystatic->canvas=$obj->canvas; + $companystatic->client=$obj->client; + $companystatic->status=$obj->status; + $companystatic->fournisseur=$obj->fournisseur; + $companystatic->code_client=$obj->code_client; + $companystatic->code_fournisseur=$obj->code_fournisseur; + $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; + $companystatic->name_alias=$obj->name_alias; + + print ""; + if (! empty($arrayfields['s.nom']['checked'])) + { + print "\n"; + } // Barcode if (! empty($arrayfields['s.barcode']['checked'])) - { - print ''; - } + { + print ''; + } // Customer code if (! empty($arrayfields['s.code_client']['checked'])) - { - print ''; - } - // Supplier code + { + print ''; + } + // Supplier code if (! empty($arrayfields['s.code_fournisseur']['checked'])) - { - print ''; - } - // Account Customer code + { + print ''; + } + // Account customer code if (! empty($arrayfields['s.code_compta']['checked'])) - { - print ''; - } - // Account Supplier code + { + print ''; + } + // Account supplier code if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) - { - print ''; - } - // Town + { + print ''; + } + // Town if (! empty($arrayfields['s.town']['checked'])) { - print ''; + print "\n"; } - // Zip + // Zip if (! empty($arrayfields['s.zip']['checked'])) { - print ''; - } - // State + print "\n"; + } + // State if (! empty($arrayfields['state.nom']['checked'])) { - print ''; - } + print "\n"; + } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; + print ''; } - // Company type + // Type ent if (! empty($arrayfields['typent.code']['checked'])) { - print ''; + print ''; + } + if (! empty($arrayfields['s.siren']['checked'])) + { + print "\n"; } - if (! empty($arrayfields['s.siren']['checked'])) - { - // IdProf1 - print ''; - } if (! empty($arrayfields['s.siret']['checked'])) { - // IdProf2 - print ''; + print "\n"; } if (! empty($arrayfields['s.ape']['checked'])) { - // IdProf3 - print ''; + print "\n"; } if (! empty($arrayfields['s.idprof4']['checked'])) { - // IdProf4 - print ''; + print "\n"; } if (! empty($arrayfields['s.idprof5']['checked'])) { - // IdProf5 - print ''; + print "\n"; } if (! empty($arrayfields['s.idprof6']['checked'])) { - // IdProf6 - print ''; + print "\n"; } - - // Type (customer/prospect/supplier) - print ''; - + // Type + print ''; if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { - // Prospect level - print ''; + // Prospect level + print '"; } - if (! empty($arrayfields['s.fk_stcomm']['checked'])) { - // Prospect status - print ''; + print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -781,267 +998,55 @@ if ($resql) { if (! empty($arrayfields["ef.".$key]['checked'])) { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; } } } // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['s.datec']['checked'])) { - print ''; } // Date modification if (! empty($arrayfields['s.tms']['checked'])) { - print ''; } // Status if (! empty($arrayfields['s.status']['checked'])) { - print ''; + print ''; } // Action column - print ''; - - print "\n"; - - $var=True; - - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - - $companystatic->id=$obj->rowid; - $companystatic->name=$obj->name; - $companystatic->canvas=$obj->canvas; - $companystatic->client=$obj->client; - $companystatic->status=$obj->status; - $companystatic->fournisseur=$obj->fournisseur; - $companystatic->code_client=$obj->code_client; - $companystatic->code_fournisseur=$obj->code_fournisseur; - $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; - $companystatic->name_alias=$obj->name_alias; - - print ""; - if (! empty($arrayfields['s.nom']['checked'])) - { - print "\n"; - } - // Barcode - if (! empty($arrayfields['s.barcode']['checked'])) - { - print ''; - } - // Customer code - if (! empty($arrayfields['s.code_client']['checked'])) - { - print ''; - } - // Supplier code - if (! empty($arrayfields['s.code_fournisseur']['checked'])) - { - print ''; - } - // Account customer code - if (! empty($arrayfields['s.code_compta']['checked'])) - { - print ''; - } - // Account supplier code - if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) - { - print ''; - } - // Town - if (! empty($arrayfields['s.town']['checked'])) - { - print "\n"; - } - // Zip - if (! empty($arrayfields['s.zip']['checked'])) - { - print "\n"; - } - // State - if (! empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - } - // Country - if (! empty($arrayfields['country.code_iso']['checked'])) - { - print ''; - } - // Type ent - if (! empty($arrayfields['typent.code']['checked'])) - { - print ''; - } - if (! empty($arrayfields['s.siren']['checked'])) - { - print "\n"; - } - if (! empty($arrayfields['s.siret']['checked'])) - { - print "\n"; - } - if (! empty($arrayfields['s.ape']['checked'])) - { - print "\n"; - } - if (! empty($arrayfields['s.idprof4']['checked'])) - { - print "\n"; - } - if (! empty($arrayfields['s.idprof5']['checked'])) - { - print "\n"; - } - if (! empty($arrayfields['s.idprof6']['checked'])) - { - print "\n"; - } - // Type - print ''; - if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) - { - // Prospect level - print '"; - } - if (! empty($arrayfields['s.fk_stcomm']['checked'])) - { - // Prospect status - print ''; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['s.datec']['checked'])) - { - print ''; - } - // Date modification - if (! empty($arrayfields['s.tms']['checked'])) - { - print ''; - } - // Status - if (! empty($arrayfields['s.status']['checked'])) - { - print ''; - } - // Action column - print ''; - - print ''."\n"; - $i++; - } - - $db->free($resql); - - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
'; + if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; +if ($type != '') print ''; +print ''; + $options_from = ''; // Generate in $options_from the list of each option sorted + foreach ($tab_level as $tab_level_sortorder => $tab_level_label) + { + $options_from .= ''; + } + array_reverse($tab_level, true); // Reverse the list + $options_to = ''; // Generate in $options_to the list of each option sorted in the reversed order + foreach ($tab_level as $tab_level_sortorder => $tab_level_label) + { + $options_to .= ''; + } + + // Print these two select + print $langs->trans("From").' '; + print ' '; + print $langs->trans("to").' '; + + print ''; + $arraystcomm=array(); + foreach($prospectstatic->cacheprospectstatus as $key => $val) + { + $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + } + print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); + print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
"; + print $companystatic->getNomUrl(1,'',100); + print "'; - print ''; - print ''.$obj->barcode.''; - print ''; - print ''.$obj->code_client.''; - print ''; - print ''.$obj->code_fournisseur.''; - print ''; - print ''.$obj->code_compta.''; - print ''; - print ''.$obj->code_compta_fournisseur.''; - print ''; - print '".$obj->town."'; - print ''; - print '".$obj->zip."'; - print ''; - print '".$obj->state_name."'; - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); - print ''; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); - print ''; + if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print '".$obj->idprof1."'; - print ''; - print ''; - print ''; - print '".$obj->idprof2."'; - print ''; - print '".$obj->idprof3."'; - print ''; - print '".$obj->idprof4."'; - print ''; - print '".$obj->idprof5."'; - print ''; - print '".$obj->idprof6."'; - if ($type != '') print ''; - print ''; + $s=''; + if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $companystatic->name=$langs->trans("Customer"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'customer'); + } + if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Prospect"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'prospect'); + } + if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) + { + if ($s) $s.=" / "; + $companystatic->name=$langs->trans("Supplier"); + $companystatic->name_alias=''; + $s.=$companystatic->getNomUrl(0,'supplier'); + } + print $s; + print ''; - $options_from = ''; // Generate in $options_from the list of each option sorted - foreach ($tab_level as $tab_level_sortorder => $tab_level_label) - { - $options_from .= ''; - } - array_reverse($tab_level, true); // Reverse the list - $options_to = ''; // Generate in $options_to the list of each option sorted in the reversed order - foreach ($tab_level as $tab_level_sortorder => $tab_level_label) - { - $options_to .= ''; - } - - // Print these two select - print $langs->trans("From").' '; - print ' '; - print $langs->trans("to").' '; - - print ''; + print $companystatic->getLibProspLevel(); + print "'; - $arraystcomm=array(); + // Prospect status + print '
'; + print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']); + print '
-
'; foreach($prospectstatic->cacheprospectstatus as $key => $val) { - $arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']); + $titlealt='default'; + if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; + if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; } - print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2); - print '
'; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); - print ''.$companystatic->getLibStatut(3).''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
"; - print $companystatic->getNomUrl(1,'',100); - print "'.$obj->barcode.''.$obj->code_client.''.$obj->code_fournisseur.''.$obj->code_compta.''.$obj->code_compta_fournisseur.'".$obj->town."".$obj->zip."".$obj->state_name."'; - $tmparray=getCountry($obj->fk_pays,'all'); - print $tmparray['label']; - print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); - print $typenArray[$obj->typent_code]; - print '".$obj->idprof1."".$obj->idprof2."".$obj->idprof3."".$obj->idprof4."".$obj->idprof5."".$obj->idprof6."'; - $s=''; - if (($obj->client==1 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - $companystatic->name=$langs->trans("Customer"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'customer'); - } - if (($obj->client==2 || $obj->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Prospect"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'prospect'); - } - if (! empty($conf->fournisseur->enabled) && $obj->fournisseur) - { - if ($s) $s.=" / "; - $companystatic->name=$langs->trans("Supplier"); - $companystatic->name_alias=''; - $s.=$companystatic->getNomUrl(0,'supplier'); - } - print $s; - print ''; - print $companystatic->getLibProspLevel(); - print "
'; - print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id,2,$prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label']); - print '
-
'; - foreach($prospectstatic->cacheprospectstatus as $key => $val) - { - $titlealt='default'; - if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label']; - if ($obj->stcomm_id != $val['id']) print ''.img_action($titlealt,$val['code']).''; - } - print '
'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$companystatic->getLibStatut(3).'
"; - - print ''; + print ''; + print ''."\n"; + $i++; } -else -{ - dol_print_error($db); -} + +$db->free($resql); + +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ""; + +print ''; llxFooter(); - $db->close();