forked from Wavyzz/dolibarr
NEW Uniformize way of working for search filters. One filter per object.
This commit is contained in:
@@ -90,56 +90,40 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
$max=3;
|
||||
|
||||
|
||||
/*
|
||||
* Search invoices
|
||||
*/
|
||||
// Search customer invoices
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/compta/facture/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td colspan="3">'.$langs->trans("SearchACustomerInvoice").'</td></tr>';
|
||||
print "<tr ".$bc[0]."><td><label for=\"sf_ref\">".$langs->trans("Ref").'</label>:</td><td><input type="text" name="sf_ref" id="sf_ref" class="flat" size="18"></td>';
|
||||
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
|
||||
print "<tr ".$bc[0]."><td><label for=\"sall\">".$langs->trans("Other").'</label>:</td><td><input type="text" name="sall" id="sall" class="flat" size="18"></td>';
|
||||
print '</tr>';
|
||||
print "</table></form><br>";
|
||||
$listofsearchfields['search_invoice']=array('text'=>'CustomerInvoice');
|
||||
}
|
||||
|
||||
/*
|
||||
* Search supplier invoices
|
||||
*/
|
||||
// Search supplier invoices
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
|
||||
{
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/fourn/facture/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchASupplierInvoice").'</td></tr>';
|
||||
print "<tr ".$bc[0].">";
|
||||
print "<td><label for=\"search_ref\">".$langs->trans("Ref").'</label>:</td><td><input type="text" name="search_ref" id="search_ref" class="flat" size="18"></td>';
|
||||
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
|
||||
print "<tr ".$bc[0]."><td><label for=\"search_ref_supplier\">".$langs->trans("RefSupplier").'</label>:</td><td><input type="text" name="search_ref_supplier" id="search_ref_supplier" class="flat" size="18"></td>';
|
||||
print '</tr>';
|
||||
print "</table></form><br>";
|
||||
$listofsearchfields['search_supplier_invoice']=array('text'=>'SupplierInvoice');
|
||||
}
|
||||
|
||||
/*
|
||||
* Search donations
|
||||
*/
|
||||
if (! empty($conf->don->enabled) && $user->rights->don->lire)
|
||||
{
|
||||
$langs->load("donations");
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/don/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchADonation").'</td></tr>';
|
||||
print "<tr ".$bc[0].">";
|
||||
print "<td><label for=\"search_ref\">".$langs->trans("Ref").'</label>:</td><td><input type="text" name="search_ref" id="search_ref" class="flat" size="18"></td>';
|
||||
print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
//print "<tr ".$bc[0]."><td><label for=\"sall\"".$langs->trans("Other").'</label>:</td><td><input type="text" name="sall" id="sall" class="flat" size="18"></td>';
|
||||
print '</tr>';
|
||||
print "</table></form><br>";
|
||||
$listofsearchfields['search_donation']=array('text'=>'Donation');
|
||||
}
|
||||
|
||||
if (count($listofsearchfields))
|
||||
{
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i=0;
|
||||
foreach($listofsearchfields as $key => $value)
|
||||
{
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
print '<tr>';
|
||||
print '<td class="nowrap"><label for="search_contract">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat" name="'.$key.'" id="'.$key.'" size="18"></td>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,7 @@ $contactid = GETPOST('id','int');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'contact', $contactid,'');
|
||||
|
||||
$sall=GETPOST("sall");
|
||||
$search_firstlast_only=GETPOST("search_firstlast_only");
|
||||
$search_lastname=GETPOST("search_lastname");
|
||||
$search_firstname=GETPOST("search_firstname");
|
||||
@@ -56,13 +57,13 @@ $search_priv=GETPOST("search_priv");
|
||||
$search_categ=GETPOST("search_categ",'int');
|
||||
$search_status=GETPOST("search_status",'int');
|
||||
if ($search_status=='') $search_status=1; // always display activ customer first
|
||||
|
||||
$optioncss = GETPOST('optioncss','alpha');
|
||||
|
||||
|
||||
$type=GETPOST("type");
|
||||
$view=GETPOST("view");
|
||||
|
||||
$sall=GETPOST("contactname");
|
||||
$sortfield = GETPOST('sortfield', 'alpha');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page', 'int');
|
||||
@@ -98,8 +99,9 @@ else if ($type == "o")
|
||||
$urlfiche="";
|
||||
}
|
||||
|
||||
if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter')) // Both tests are required to be compatible with all browsers
|
||||
if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
$sall="";
|
||||
$search_firstlast_only="";
|
||||
$search_lastname="";
|
||||
$search_firstname="";
|
||||
@@ -113,7 +115,6 @@ if (GETPOST('button_removefilter_x') || GETPOST('button_removefilter')) // Both
|
||||
$search_email="";
|
||||
$search_skype="";
|
||||
$search_priv="";
|
||||
$sall="";
|
||||
$seach_status=1;
|
||||
}
|
||||
if ($search_priv < 0) $search_priv='';
|
||||
|
||||
@@ -64,7 +64,40 @@ if (GETPOST('search_contract') != '')
|
||||
header("Location: ".DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode(GETPOST('search_contract')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_invoice') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/facture/list.php?sall='.urlencode(GETPOST('search_invoice')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_supplier_invoice') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/fourn/facture/list.php?sall='.urlencode(GETPOST('search_supplier_invoice')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_donation') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/don/list.php?sall='.urlencode(GETPOST('search_donation')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_product') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/product/list.php?sall='.urlencode(GETPOST('search_product')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_thirdparty') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/societe/list.php?mode=search&sall='.urlencode(GETPOST('search_thirdparty')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_contact') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact')));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// If we are here, search was called with no supported criteria
|
||||
if (! empty($_SERVER['HTTP_REFERER']))
|
||||
{
|
||||
|
||||
@@ -70,14 +70,14 @@ $searchform = '';
|
||||
if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname');
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'sall', '', 'company');
|
||||
$nbofsearch++;
|
||||
}
|
||||
|
||||
if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname');
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'sall', '', 'contact');
|
||||
$nbofsearch++;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! em
|
||||
&& ! empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE))
|
||||
{
|
||||
$langs->load("products");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/product/list.php', DOL_URL_ROOT.'/product/list.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall', '', 'sall'.rand(0,10));
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/product/list.php', DOL_URL_ROOT.'/product/list.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall', '', 'product');
|
||||
$nbofsearch++;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! em
|
||||
if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_ADHERENT) && $user->rights->adherent->lire)
|
||||
{
|
||||
$langs->load("members");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/list.php', DOL_URL_ROOT.'/adherents/list.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall', 'sall'.rand(0,10));
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/list.php', DOL_URL_ROOT.'/adherents/list.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall', '', 'member');
|
||||
$nbofsearch++;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ if (! $sortfield) $sortfield="d.datedon";
|
||||
$limit = $conf->liste_limit;
|
||||
|
||||
$statut=isset($_GET["statut"])?$_GET["statut"]:"-1";
|
||||
$search_all=GETPOST('sall','alpha');
|
||||
$search_ref=GETPOST('search_ref','alpha');
|
||||
$search_company=GETPOST('search_company','alpha');
|
||||
$search_name=GETPOST('search_name','alpha');
|
||||
@@ -51,9 +52,10 @@ $optioncss = GETPOST('optioncss','alpha');
|
||||
|
||||
if (!$user->rights->don->lire) accessforbidden();
|
||||
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$search_ref="";
|
||||
$search_all="";
|
||||
$search_ref="";
|
||||
$search_company="";
|
||||
$search_name="";
|
||||
$search_amount="";
|
||||
@@ -83,6 +85,10 @@ if (trim($search_ref) != '')
|
||||
{
|
||||
$sql.= ' AND d.rowid LIKE \'%'.$db->escape(trim($search_ref)) . '%\'';
|
||||
}
|
||||
if (trim($search_all) != '')
|
||||
{
|
||||
$sql .= natural_search(array('d.rowid', 'd.ref', 'd.lastname', 'd.firstname', 'd.societe'), $search_all);
|
||||
}
|
||||
if (trim($search_company) != '')
|
||||
{
|
||||
$sql .= natural_search('d.societe', $search_company);
|
||||
|
||||
@@ -1575,13 +1575,13 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
||||
if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'soc', 'socname', 'T', 'searchleftt', img_object('','company'));
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'soc', 'sall', 'T', 'searchleftt', img_object('','company'));
|
||||
}
|
||||
|
||||
if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', $langs->trans("Contacts"), 'contact', 'contactname', '', 'searchleftc', img_object('','contact'));
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', $langs->trans("Contacts"), 'contact', 'sall', 'A', 'searchleftc', img_object('','contact'));
|
||||
}
|
||||
|
||||
if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire))
|
||||
@@ -1607,7 +1607,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me
|
||||
if (! empty($conf->projet->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_PROJECT) && $user->rights->projet->lire)
|
||||
{
|
||||
$langs->load("members");
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'M', 'searchleftproj', img_object('','projectpub'));
|
||||
$searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub'));
|
||||
}
|
||||
|
||||
// Execute hook printSearchForm
|
||||
@@ -1851,11 +1851,11 @@ function getHelpParamFor($helppagename,$langs)
|
||||
* @param string $htmlmodesearch Value to set into parameter "mode_search" ('soc','contact','products','member',...)
|
||||
* @param string $htmlinputname Field Name input form
|
||||
* @param string $accesskey Accesskey
|
||||
* @param string $idname Complement for id to avoid multiple same id in the page
|
||||
* @param string $prefhtmlinputname Complement for id to avoid multiple same id in the page
|
||||
* @param string $img Image to use
|
||||
* @return string
|
||||
*/
|
||||
function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinputname,$accesskey='', $idname='',$img='')
|
||||
function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinputname,$accesskey='', $prefhtmlinputname='',$img='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@@ -1868,7 +1868,7 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinput
|
||||
$ret.='<div class="menu_titre menu_titre_search"';
|
||||
if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $ret.=' style="display: inline-block"';
|
||||
$ret.='>';
|
||||
$ret.='<label for="'.$idname.$htmlinputname.'">';
|
||||
$ret.='<label for="'.$prefhtmlinputname.$htmlinputname.'">';
|
||||
$ret.='<a class="vsmenu" href="'.$urlobject.'">';
|
||||
if ($img && ! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $ret.=$img;
|
||||
else $ret.=$img.' '.$title;
|
||||
@@ -1882,7 +1882,7 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch,$htmlinput
|
||||
$ret.=($accesskey?' accesskey="'.$accesskey.'"':'');
|
||||
if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $ret.=' placeholder="'.strip_tags($title).'"'; // Will work only if MAIN_HTML5_PLACEHOLDER is set to 1
|
||||
else $ret.=' title="'.$langs->trans("SearchOf").''.strip_tags($title).'"';
|
||||
$ret.=' name="'.$htmlinputname.'" id="'.$idname.$htmlinputname.'" size="10" />';
|
||||
$ret.=' name="'.$htmlinputname.'" id="'.$prefhtmlinputname.$htmlinputname.'" size="10" />';
|
||||
$ret.='<input type="submit" class="button" style="padding-top: 4px; padding-bottom: 4px; padding-left: 6px; padding-right: 6px" value="'.$langs->trans("Go").'">';
|
||||
$ret.="</form>\n";
|
||||
return $ret;
|
||||
|
||||
@@ -78,29 +78,32 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
/*
|
||||
* Search Area of product/service
|
||||
*/
|
||||
$rowspan=2;
|
||||
if (! empty($conf->barcode->enabled)) $rowspan++;
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/product/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print '<td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
print "<tr ".$bc[false]."><td>";
|
||||
print '<label for="sref">'.$langs->trans("Ref").'</label>:</td><td><input class="flat" type="text" size="14" name="sref" id="sref"></td>';
|
||||
print '<td rowspan="'.$rowspan.'"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
|
||||
if (! empty($conf->barcode->enabled))
|
||||
|
||||
// Search contract
|
||||
if ((! empty($conf->product->enabled) || ! empty($conf->service->enabled)) && ($user->rights->produit->lire || $user->rights->service->lire))
|
||||
{
|
||||
print "<tr ".$bc[false]."><td>";
|
||||
print '<label for="barcode">'.$langs->trans("BarCode").'</label>:</td><td><input class="flat" type="text" size="14" name="sbarcode" id="barcode"></td>';
|
||||
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
|
||||
print '</tr>';
|
||||
$listofsearchfields['search_product']=array('text'=>'ProductOrService');
|
||||
}
|
||||
print "<tr ".$bc[false]."><td>";
|
||||
print '<label for="sall">'.$langs->trans("Other").'</label>:</td><td><input class="flat" type="text" size="14" name="sall" id="sall"></td>';
|
||||
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
|
||||
print '</tr>';
|
||||
print "</table></form><br>";
|
||||
|
||||
if (count($listofsearchfields))
|
||||
{
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i=0;
|
||||
foreach($listofsearchfields as $key => $value)
|
||||
{
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
print '<tr>';
|
||||
print '<td class="nowrap"><label for="search_contract">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat" name="'.$key.'" id="'.$key.'" size="18"></td>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Number of products and/or services
|
||||
|
||||
@@ -92,6 +92,7 @@ else $result=restrictedArea($user,'produit|service','','','','','',$objcanvas);
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$sref="";
|
||||
$sall="";
|
||||
$sbarcode="";
|
||||
$snom="";
|
||||
$search_categ=0;
|
||||
|
||||
@@ -56,54 +56,43 @@ print load_fiche_titre($transAreaType,$linkback,'title_companies.png');
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
|
||||
/*
|
||||
* Search area
|
||||
*/
|
||||
$rowspan=2;
|
||||
if (! empty($conf->barcode->enabled)) $rowspan++;
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/societe/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="3">'.$langs->trans("SearchThirdparty").'</th></tr>';
|
||||
print "<tr ".$bc[false]."><td>";
|
||||
print '<label for="search_nom_only">'.$langs->trans("Name").'</label>:</td><td><input class="flat" type="text" size="14" name="search_nom_only" id="search_nom_only"></td>';
|
||||
print '<td rowspan="'.$rowspan.'"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
|
||||
if (! empty($conf->barcode->enabled))
|
||||
{
|
||||
print "<tr ".$bc[false]."><td ".$bc[false].">";
|
||||
print '<label for="sbarcode">'.$langs->trans("BarCode").'</label>:</td><td><input class="flat" type="text" size="14" name="sbarcode" id="sbarcode"></td>';
|
||||
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print "<tr ".$bc[false]."><td ".$bc[false].">";
|
||||
print '<label for="search_all">'.$langs->trans("Other").'</label>:</td><td '.$bc[false].'><input class="flat" type="text" size="14" name="search_all" id="search_all"></td>';
|
||||
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
|
||||
print '</tr>'."\n";
|
||||
print "</table></form><br>\n";
|
||||
|
||||
/*
|
||||
* Search contact
|
||||
*/
|
||||
$rowspan=2;
|
||||
if (! empty($conf->barcode->enabled)) $rowspan++;
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/contact/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
|
||||
print '<table class="noborder nohover" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th colspan="3">'.$langs->trans("SearchContact").'</th></tr>'."\n";
|
||||
print "<tr ".$bc[false]."><td>";
|
||||
print '<label for="search_nom_only">'.$langs->trans("Name").'</label>:</td><td><input class="flat" type="text" size="14" name="search_firstlast_only" id="search_firstlast_only"></td>';
|
||||
print '<td rowspan="'.$rowspan.'"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>'."\n";
|
||||
print "<tr ".$bc[false]."><td ".$bc[false].">";
|
||||
print '<label for="search_all">'.$langs->trans("Other").'</label>:</td><td '.$bc[false].'><input class="flat" type="text" size="14" name="contactname" id="contactname"></td>';
|
||||
//print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
|
||||
print '</tr>'."\n";
|
||||
print "</table></form><br>\n";
|
||||
// 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 '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i=0;
|
||||
foreach($listofsearchfields as $key => $value)
|
||||
{
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
print '<tr>';
|
||||
print '<td class="nowrap"><label for="search_contract">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat" name="'.$key.'" id="'.$key.'" size="18"></td>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Statistics area
|
||||
*/
|
||||
|
||||
$third = array(
|
||||
'customer' => 0,
|
||||
'prospect' => 0,
|
||||
|
||||
@@ -43,11 +43,10 @@ $result = restrictedArea($user,'societe',$socid,'');
|
||||
|
||||
$search_nom=trim(GETPOST("search_nom"));
|
||||
$search_nom_only=trim(GETPOST("search_nom_only"));
|
||||
$search_all=trim(GETPOST("search_all"));
|
||||
$search_all=trim(GETPOST("sall"));
|
||||
$sbarcode=trim(GETPOST("sbarcode"));
|
||||
$search_town=trim(GETPOST("search_town"));
|
||||
$search_zip=trim(GETPOST("search_zip"));
|
||||
$socname=trim(GETPOST("socname"));
|
||||
$search_idprof1=trim(GETPOST('search_idprof1'));
|
||||
$search_idprof2=trim(GETPOST('search_idprof2'));
|
||||
$search_idprof3=trim(GETPOST('search_idprof3'));
|
||||
@@ -63,7 +62,6 @@ $search_status=GETPOST("search_status",'int');
|
||||
|
||||
$optioncss=GETPOST('optioncss','alpha');
|
||||
$mode=GETPOST("mode");
|
||||
$modesearch=GETPOST("mode_search");
|
||||
|
||||
$sortfield=GETPOST("sortfield",'alpha');
|
||||
$sortorder=GETPOST("sortorder",'alpha');
|
||||
@@ -84,6 +82,21 @@ $extrafields = new ExtraFields($db);
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('thirdparty');
|
||||
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
||||
|
||||
$fieldstosearchall = array(
|
||||
's.nom',
|
||||
's.name_alias',
|
||||
's.code_client',
|
||||
"s.code_fournisseur",
|
||||
's.email',
|
||||
's.url',
|
||||
's.siren',
|
||||
's.siret',
|
||||
's.ape',
|
||||
"s.idprof4","s.idprof5","s.idprof6",
|
||||
's.tva_intra'
|
||||
);
|
||||
if (!empty($conf->barcode->enabled)) $fieldstosearchall[] = 's.barcode';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@@ -94,34 +107,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
// special search
|
||||
if ($mode == 'search')
|
||||
{
|
||||
$search_nom=$socname;
|
||||
|
||||
$sql = "SELECT s.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
// We'll need this table joined to the select in order to filter by categ
|
||||
if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
|
||||
|
||||
// For natural search
|
||||
$scrit = explode(' ', $socname);
|
||||
|
||||
$fields = array(
|
||||
's.nom',
|
||||
's.code_client',
|
||||
's.email',
|
||||
's.url',
|
||||
's.siren',
|
||||
's.name_alias'
|
||||
);
|
||||
|
||||
if (!empty($conf->barcode->enabled)) {
|
||||
$fields[] = 's.barcode';
|
||||
}
|
||||
|
||||
foreach ($scrit as $crit) {
|
||||
$sql.= natural_search($fields, $crit);
|
||||
}
|
||||
// sall criteria
|
||||
$sql.= natural_search($fields, $sall);
|
||||
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
@@ -180,8 +173,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
|
||||
{
|
||||
$search_categ='';
|
||||
$search_sale='';
|
||||
$socname="";
|
||||
$search_nom="";
|
||||
$sbarcode="";
|
||||
$search_town="";
|
||||
$search_zip="";
|
||||
@@ -198,11 +189,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
|
||||
|
||||
if ($search_status=='') $search_status=1; // always display active thirdparty first
|
||||
|
||||
if ($socname)
|
||||
{
|
||||
$search_nom=$socname;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Mode List
|
||||
@@ -251,9 +237,9 @@ if ($search_categ) $sql.= " AND s.rowid = cs.fk_soc"; // Join for the neede
|
||||
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
|
||||
if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
|
||||
if ($search_categ) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
|
||||
if ($search_nom) $sql.= natural_search("s.nom",$search_nom);
|
||||
if ($search_nom_only) $sql.= natural_search("s.nom",$search_nom_only);
|
||||
if ($search_all) $sql.= natural_search(array("s.nom", "s.name_alias", "s.code_client", "s.code_fournisseur", "s.email", "s.url","s.siren","s.siret","s.ape","s.idprof4","s.idprof5","s.idprof6"), $search_all);
|
||||
if ($search_nom) $sql.= natural_search(array("s.nom", "s.name_alias", "s.code_client", "s.code_fournisseur", "s.email", "s.url","s.siren","s.siret","s.ape","s.idprof4","s.idprof5","s.idprof6"), $search_nom);
|
||||
if ($search_all) $sql.= natural_search($fieldstosearchall, $search_all);
|
||||
if ($search_town) $sql.= natural_search("s.town",$search_town);
|
||||
if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
|
||||
if ($search_idprof1) $sql.= natural_search("s.siren",$search_idprof1);
|
||||
@@ -305,7 +291,7 @@ if ($resql)
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = "&socname=".urlencode($socname);
|
||||
$param = "&sall=".urlencode($sall);
|
||||
$param.= "&search_nom=".urlencode($search_nom);
|
||||
$param.= "&search_town=".urlencode($search_town);
|
||||
$param.= "&search_zip=".urlencode($search_zip);
|
||||
@@ -386,7 +372,7 @@ if ($resql)
|
||||
// Define list of fields to show into list
|
||||
$arrayfields=array(
|
||||
's.nom'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
|
||||
's.barcode'=>array('label'=>$langs->trans("BarCode"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
|
||||
's.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
|
||||
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
|
||||
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
|
||||
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>1),
|
||||
@@ -405,7 +391,7 @@ if ($resql)
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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("BarCode"), $_SERVER["PHP_SELF"], "s.barcode",$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.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['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
|
||||
@@ -573,7 +559,7 @@ if ($resql)
|
||||
// Barcode
|
||||
if (! empty($arrayfields['s.barcode']['checked']))
|
||||
{
|
||||
print '<td>'.$objp->barcode.'</td>';
|
||||
print '<td>'.$obj->barcode.'</td>';
|
||||
}
|
||||
// Town
|
||||
if (! empty($arrayfields['s.town']['checked']))
|
||||
|
||||
Reference in New Issue
Block a user