NEW Add filter on staff range in list of thirdparties
This commit is contained in:
parent
78e983a1f5
commit
961505d510
@ -148,29 +148,29 @@ if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate";
|
||||
|
||||
$checkedtypetiers=0;
|
||||
$arrayfields=array(
|
||||
'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||
'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
|
||||
'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0),
|
||||
'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1),
|
||||
'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1),
|
||||
'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
|
||||
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
|
||||
's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
|
||||
's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
|
||||
'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
|
||||
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
|
||||
'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
|
||||
'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1),
|
||||
'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
|
||||
'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
|
||||
'f.facnumber'=>array('label'=>"Ref", 'checked'=>1),
|
||||
'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1),
|
||||
'f.type'=>array('label'=>"Type", 'checked'=>0),
|
||||
'f.date'=>array('label'=>"DateInvoice", 'checked'=>1),
|
||||
'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1),
|
||||
'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
|
||||
's.nom'=>array('label'=>"ThirdParty", 'checked'=>1),
|
||||
's.town'=>array('label'=>"Town", 'checked'=>1),
|
||||
's.zip'=>array('label'=>"Zip", 'checked'=>1),
|
||||
'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
|
||||
'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
|
||||
'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
|
||||
'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1),
|
||||
'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
|
||||
'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
|
||||
'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")),
|
||||
'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1")),
|
||||
'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
|
||||
'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
|
||||
'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0),
|
||||
'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
||||
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
|
||||
'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||
'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
|
||||
'dynamount_payed'=>array('label'=>"Received", 'checked'=>0),
|
||||
'rtp'=>array('label'=>"Rest", 'checked'=>0),
|
||||
'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
|
||||
'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
|
||||
'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
@ -422,22 +422,14 @@ if ($filtre)
|
||||
}
|
||||
if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
|
||||
if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer);
|
||||
if ($search_type != '' && $search_type >= 0)
|
||||
{
|
||||
if ($search_type == '0') $sql.=" AND f.type = 0"; // standard
|
||||
if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement
|
||||
if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note
|
||||
if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit
|
||||
if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
|
||||
if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
|
||||
}
|
||||
if ($search_type != '') $sql.=" AND f.type IN (".$db->escape($search_type).")";
|
||||
if ($search_project) $sql .= natural_search('p.ref', $search_project);
|
||||
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
|
||||
if ($search_town) $sql.= natural_search('s.town', $search_town);
|
||||
if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
|
||||
if ($search_state) $sql.= natural_search("state.nom",$search_state);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
|
||||
if ($search_company) $sql .= natural_search('s.nom', $search_company);
|
||||
if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
|
||||
if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
|
||||
@ -1071,11 +1063,20 @@ if ($resql)
|
||||
if (! empty($arrayfields['typent.code']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
|
||||
if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
|
||||
print $typenArray[$obj->typent_code];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Staff
|
||||
if (! empty($arrayfields['staff.code']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
|
||||
print $staffArray[$obj->staff_code];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Payment mode
|
||||
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
|
||||
|
||||
@ -84,6 +84,7 @@ $search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
|
||||
$search_categ_sup=trim(GETPOST("search_categ_sup",'int'));
|
||||
$search_country=GETPOST("search_country",'intcomma');
|
||||
$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
|
||||
$search_staff=GETPOST("search_staff",'int');
|
||||
$search_status=GETPOST("search_status",'int');
|
||||
$search_type=GETPOST('search_type','alpha');
|
||||
$search_level_from = GETPOST("search_level_from","alpha");
|
||||
@ -184,6 +185,7 @@ $arrayfields=array(
|
||||
's.phone'=>array('label'=>"Phone", 'checked'=>1),
|
||||
's.fax'=>array('label'=>"Fax", 'checked'=>0),
|
||||
'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
|
||||
'staff.code'=>array('label'=>"Staff", 'checked'=>0),
|
||||
's.siren'=>array('label'=>"ProfId1Short", 'checked'=>$checkedprofid1),
|
||||
's.siret'=>array('label'=>"ProfId2Short", 'checked'=>$checkedprofid2),
|
||||
's.ape'=>array('label'=>"ProfId3Short", 'checked'=>$checkedprofid3),
|
||||
@ -258,6 +260,7 @@ if (empty($reshook))
|
||||
$search_vat='';
|
||||
$search_type='';
|
||||
$search_type_thirdparty='';
|
||||
$search_staff='';
|
||||
$search_status=-1;
|
||||
$search_stcomm='';
|
||||
$search_level_from='';
|
||||
@ -401,6 +404,7 @@ $sql.= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2,
|
||||
$sql.= " s.tms as date_update, s.datec as date_creation,";
|
||||
$sql.= " s.code_compta,s.code_compta_fournisseur,";
|
||||
$sql.= " typent.code as typent_code,";
|
||||
$sql.= " staff.code as staff_code,";
|
||||
$sql.= " country.code as country_code,";
|
||||
$sql.= " state.code_departement as state_code, state.nom as state_name,";
|
||||
$sql.= " region.code_region as region_code, region.nom as region_name";
|
||||
@ -419,6 +423,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_effectif as staff on (staff.id = s.fk_effectif)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region = state.fk_region)";
|
||||
// We'll need this table joined to the select in order to filter by categ
|
||||
@ -452,8 +457,8 @@ if ($search_account_supplier_code) $sql.= natural_search("s.code_compta_fourniss
|
||||
if ($search_town) $sql.= natural_search("s.town",$search_town);
|
||||
if (strlen($search_zip)) $sql.= natural_search("s.zip",$search_zip);
|
||||
if ($search_state) $sql.= natural_search("state.nom",$search_state);
|
||||
if ($search_region) $sql.= natural_search("region.nom",$search_region);
|
||||
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
|
||||
if ($search_region) $sql.= natural_search("region.nom",$search_region);
|
||||
if ($search_country && $search_country != '-1') $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
|
||||
if ($search_email) $sql.= natural_search("s.email",$search_email);
|
||||
if (strlen($search_phone)) $sql.= natural_search("s.phone", $search_phone);
|
||||
if (strlen($search_fax)) $sql.= natural_search("s.phone", $search_fax);
|
||||
@ -471,7 +476,8 @@ if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND
|
||||
if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
|
||||
if ($search_status!='' && $search_status >= 0) $sql .= " AND s.status = ".$db->escape($search_status);
|
||||
if (!empty($conf->barcode->enabled) && $search_barcode) $sql.= natural_search("s.barcode", $search_barcode);
|
||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
|
||||
if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql.= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
|
||||
if (! empty($search_staff) && $search_staff != '-1') $sql.= " AND s.fk_effectif IN (".$db->escape($search_staff).")";
|
||||
if ($search_levels) $sql .= " AND s.fk_prospectlevel IN (".$search_levels.')';
|
||||
if ($search_stcomm != '' && $search_stcomm != -2) $sql.= natural_search("s.fk_stcomm",$search_stcomm,2);
|
||||
if ($search_import_key) $sql.= natural_search("s.import_key",$search_import_key);
|
||||
@ -796,6 +802,13 @@ if (! empty($arrayfields['typent.code']['checked']))
|
||||
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 '</td>';
|
||||
}
|
||||
// Staff
|
||||
if (! empty($arrayfields['staff.code']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
|
||||
print $form->selectarray("search_staff", $formcompany->effectif_array(0), $search_staff, 0, 0, 0, '', 0, 0, 0, $sort, 'maxwidth100');
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['s.email']['checked']))
|
||||
{
|
||||
// Email
|
||||
@ -983,6 +996,7 @@ if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titr
|
||||
if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['staff.code']['checked'])) print_liste_field_titre($arrayfields['staff.code']['label'],$_SERVER["PHP_SELF"],"staff.code","",$param,'align="center"',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.phone']['checked'])) print_liste_field_titre($arrayfields['s.phone']['label'],$_SERVER["PHP_SELF"],"s.phone","",$param,'',$sortfield,$sortorder);
|
||||
if (! empty($arrayfields['s.fax']['checked'])) print_liste_field_titre($arrayfields['s.fax']['label'],$_SERVER["PHP_SELF"],"s.fax","",$param,'',$sortfield,$sortorder);
|
||||
@ -1131,6 +1145,15 @@ while ($i < min($num, $limit))
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Staff
|
||||
if (! empty($arrayfields['staff.code']['checked']))
|
||||
{
|
||||
print '<td align="center">';
|
||||
if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
|
||||
print $staffArray[$obj->staff_code];
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
}
|
||||
if (! empty($arrayfields['s.email']['checked']))
|
||||
{
|
||||
print "<td>".$obj->email."</td>\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user