Просмотр исходного кода

MMICore add email field to lists propal, orders, invoices and globally search by email

Mathieu Moulin 2 лет назад
Родитель
Сommit
e794eb687c
3 измененных файлов с 88 добавлено и 4 удалено
  1. 31 1
      htdocs/comm/propal/list.php
  2. 28 1
      htdocs/commande/list.php
  3. 29 2
      htdocs/compta/facture/list.php

+ 31 - 1
htdocs/comm/propal/list.php

@@ -90,6 +90,7 @@ $search_town = GETPOST('search_town', 'alpha');
 $search_zip = GETPOST('search_zip', 'alpha');
 $search_state = GETPOST("search_state");
 $search_country = GETPOST("search_country", 'int');
+$search_email = GETPOST('search_email', 'alpha');
 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
 $search_date_startday = GETPOST('search_date_startday', 'int');
 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
@@ -193,6 +194,7 @@ $fieldstosearchall = array(
 	's.name_alias'=>"AliasNameShort",
 	's.zip'=>"Zip",
 	's.town'=>"Town",
+	's.email'=>"Email",
 	'p.note_public'=>'NotePublic',
 );
 if (empty($user->socid)) {
@@ -212,6 +214,7 @@ $arrayfields = array(
 	's.zip'=>array('label'=>"Zip", 'checked'=>-1),
 	'state.nom'=>array('label'=>"StateShort", 'checked'=>0),
 	'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
+	's.email'=>array('label'=>"Email", 'checked'=>0),
 	'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers),
 	'p.date'=>array('label'=>"DatePropal", 'checked'=>1),
 	'p.fin_validite'=>array('label'=>"DateEnd", 'checked'=>1),
@@ -312,6 +315,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
 	$search_state = "";
 	$search_type = '';
 	$search_country = '';
+	$search_email = "";
 	$search_type_thirdparty = '';
 	$search_date_startday = '';
 	$search_date_startmonth = '';
@@ -527,7 +531,7 @@ $sql = 'SELECT';
 if ($sall || $search_product_category > 0 || $search_user > 0) {
 	$sql = 'SELECT DISTINCT';
 }
-$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax , s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client, ';
+$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax , s.address, s.town, s.zip, s.fk_pays, s.email, s.client, s.code_client, ';
 $sql .= " typent.code as typent_code,";
 $sql .= " ava.rowid as availability,";
 $sql .= " country.code as country_code,";
@@ -624,6 +628,9 @@ if ($search_state) {
 if ($search_country) {
 	$sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
 }
+if ($search_email) {
+	$sql .= natural_search("s.email", $search_email);
+}
 if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
 	$sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
 }
@@ -915,6 +922,9 @@ if ($resql) {
 	if ($search_zip) {
 		$param .= '&search_zip='.urlencode($search_zip);
 	}
+	if ($search_email) {
+		$param .= '&search_email='.urlencode($search_email);
+	}
 	if ($socid > 0) {
 		$param .= '&socid='.urlencode($socid);
 	}
@@ -957,6 +967,9 @@ if ($resql) {
 	if ($search_country) {
 		$param .= '&search_country='.urlencode($search_country);
 	}
+	if ($search_email) {
+		$param .= '&search_email='.urlencode($search_email);
+	}
 	if ($search_date_signature_startday) {
 		$param .= '&search_date_signature_startday='.urlencode($search_date_signature_startday);
 	}
@@ -1166,6 +1179,10 @@ if ($resql) {
 		print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
 		print '</td>';
 	}
+	// Email
+	if (!empty($arrayfields['s.email']['checked'])) {
+		print '<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_email" value="'.$search_email.'"></td>';
+	}
 	// Company type
 	if (!empty($arrayfields['typent.code']['checked'])) {
 		print '<td class="liste_titre maxwidth100onsmartphone" align="center">';
@@ -1428,6 +1445,9 @@ if ($resql) {
 	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['s.email']['checked'])) {
+		print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], 's.email', '', $param, '', $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);
 	}
@@ -1589,6 +1609,7 @@ if ($resql) {
 		$companystatic->zip = $obj->zip;
 		$companystatic->town = $obj->town;
 		$companystatic->country_code = $obj->country_code;
+		$companystatic->email = $obj->email;
 
 		$projectstatic->id = $obj->project_id;
 		$projectstatic->ref = $obj->project_ref;
@@ -1748,6 +1769,15 @@ if ($resql) {
 				$totalarray['nbfield']++;
 			}
 		}
+		// Email
+		if (!empty($arrayfields['s.email']['checked'])) {
+			print '<td class="nocellnopadd">';
+			print $obj->email;
+			print '</td>';
+			if (!$i) {
+				$totalarray['nbfield']++;
+			}
+		}
 		// Type ent
 		if (!empty($arrayfields['typent.code']['checked'])) {
 			if (!is_array($typenArray) || empty($typenArray)) {

+ 28 - 1
htdocs/commande/list.php

@@ -81,6 +81,7 @@ $search_town = GETPOST('search_town', 'alpha');
 $search_zip = GETPOST('search_zip', 'alpha');
 $search_state = GETPOST("search_state", 'alpha');
 $search_country = GETPOST("search_country", 'int');
+$search_email = GETPOST('search_email', 'alpha');
 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
 $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
 $socid = GETPOST('socid', 'int');
@@ -158,6 +159,7 @@ $fieldstosearchall = array(
 	's.name_alias'=>"AliasNameShort",
 	's.zip'=>"Zip",
 	's.town'=>"Town",
+	's.email'=>"Email",
 	'c.note_public'=>'NotePublic',
 );
 if (empty($user->socid)) {
@@ -176,6 +178,7 @@ $arrayfields = array(
 	's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40),
 	'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45),
 	'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50),
+	's.email'=>array('label'=>"Email", 'checked'=>0, 'position'=>51),
 	'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55),
 	'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60),
 	'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65),
@@ -251,6 +254,7 @@ if (empty($reshook)) {
 		$search_state = "";
 		$search_type = '';
 		$search_country = '';
+		$search_email = "";
 		$search_type_thirdparty = '';
 		$search_total_ht = '';
 		$search_total_vat = '';
@@ -783,7 +787,7 @@ $sql = 'SELECT';
 if ($sall || $search_product_category > 0 || $search_user > 0) {
 	$sql = 'SELECT DISTINCT';
 }
-$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
+$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.email, s.client, s.code_client,';
 $sql .= " typent.code as typent_code,";
 $sql .= " state.code_departement as state_code, state.nom as state_name,";
 $sql .= " country.code as country_code,";
@@ -917,6 +921,9 @@ if ($search_state) {
 if ($search_country) {
 	$sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
 }
+if ($search_email) {
+	$sql .= natural_search("s.email", $search_email);
+}
 if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
 	$sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')';
 }
@@ -1164,6 +1171,9 @@ if ($resql) {
 	if ($search_country != '') {
 		$param .= '&search_country='.urlencode($search_country);
 	}
+	if ($search_email != '') {
+		$param .= '&search_email='.urlencode($search_email);
+	}
 	if ($search_type_thirdparty && $search_type_thirdparty != '-1') {
 		$param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
 	}
@@ -1450,6 +1460,10 @@ if ($resql) {
 		print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
 		print '</td>';
 	}
+	// Email
+	if (!empty($arrayfields['s.email']['checked'])) {
+		print '<td class="liste_titre"><input class="flat maxwidth100" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
+	}
 	// Company type
 	if (!empty($arrayfields['typent.code']['checked'])) {
 		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
@@ -1689,6 +1703,9 @@ if ($resql) {
 	if (!empty($arrayfields['country.code_iso']['checked'])) {
 		print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
 	}
+	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['typent.code']['checked'])) {
 		print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
 	}
@@ -1852,6 +1869,7 @@ if ($resql) {
 		$companystatic->zip = $obj->zip;
 		$companystatic->town = $obj->town;
 		$companystatic->country_code = $obj->country_code;
+		$companystatic->email = $obj->email;
 		if (!isset($getNomUrl_cache[$obj->socid])) {
 			$getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer');
 		}
@@ -1995,6 +2013,15 @@ if ($resql) {
 				$totalarray['nbfield']++;
 			}
 		}
+		// Email
+		if (!empty($arrayfields['s.email']['checked'])) {
+			print '<td class="nocellnopadd">';
+			print $obj->email;
+			print '</td>';
+			if (!$i) {
+				$totalarray['nbfield']++;
+			}
+		}
 		// Type ent
 		if (!empty($arrayfields['typent.code']['checked'])) {
 			print '<td class="center">';

+ 29 - 2
htdocs/compta/facture/list.php

@@ -108,6 +108,7 @@ $search_town = GETPOST('search_town', 'alpha');
 $search_zip = GETPOST('search_zip', 'alpha');
 $search_state = GETPOST("search_state");
 $search_country = GETPOST("search_country", 'alpha');
+$search_email = GETPOST('search_email', 'alpha');
 $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
 $search_user = GETPOST('search_user', 'int');
 $search_sale = GETPOST('search_sale', 'int');
@@ -200,6 +201,7 @@ $fieldstosearchall = array(
 	's.name_alias'=>"AliasNameShort",
 	's.zip'=>"Zip",
 	's.town'=>"Town",
+	's.email'=>"Email",
 	'pd.description'=>'Description',
 );
 if (empty($user->socid)) {
@@ -223,6 +225,7 @@ $arrayfields = array(
 	's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60),
 	'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>65),
 	'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>70),
+	's.email'=>array('label'=>"Email", 'checked'=>0, 'position'=>71),
 	'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>75),
 	'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>80),
 	'f.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>1, 'position'=>85),
@@ -337,6 +340,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter',
 	$search_state = "";
 	$search_type = '';
 	$search_country = '';
+	$search_email = "";
 	$search_type_thirdparty = '';
 	$search_date_startday = '';
 	$search_date_startmonth = '';
@@ -565,7 +569,7 @@ $sql .= ' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_so
 $sql .= ' f.paye as paye, f.fk_statut, f.close_code,';
 $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,';
 $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
-$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
+$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,';
 $sql .= ' typent.code as typent_code,';
 $sql .= ' state.code_departement as state_code, state.nom as state_name,';
 $sql .= ' country.code as country_code,';
@@ -688,6 +692,9 @@ if ($search_zip) {
 if ($search_state) {
 	$sql .= natural_search("state.nom", $search_state);
 }
+if ($search_email) {
+	$sql .= natural_search("s.email", $search_email);
+}
 if (strlen(trim($search_country))) {
 	$arrayofcode = getCountriesInEEC();
 	$country_code_in_EEC = $country_code_in_EEC_without_me = '';
@@ -830,7 +837,7 @@ if (!$sall) {
 	$sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
 	$sql .= ' f.fk_user_author, f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht,';
 	$sql .= ' f.multicurrency_total_tva, f.multicurrency_total_ttc,';
-	$sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
+	$sql .= ' s.rowid, s.nom, s.name_alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
 	$sql .= ' typent.code,';
 	$sql .= ' state.code_departement, state.nom,';
 	$sql .= ' country.code,';
@@ -1021,6 +1028,9 @@ if ($resql) {
 	if ($search_country) {
 		$param .= "&search_country=".urlencode($search_country);
 	}
+	if ($search_email) {
+		$param .= '&search_email='.urlencode($search_email);
+	}
 	if ($search_sale > 0) {
 		$param .= '&search_sale='.urlencode($search_sale);
 	}
@@ -1347,6 +1357,10 @@ if ($resql) {
 		print $form->select_country($search_country, 'search_country', '', 0, 'minwidth150imp maxwidth150', 'code2', 1, 0, 1, null, 1);
 		print '</td>';
 	}
+	// Email
+	if (!empty($arrayfields['s.email']['checked'])) {
+		print '<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'"></td>';
+	}
 	// Company type
 	if (!empty($arrayfields['typent.code']['checked'])) {
 		print '<td class="liste_titre maxwidthonsmartphone" align="center">';
@@ -1581,6 +1595,9 @@ if ($resql) {
 	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['s.email']['checked'])) {
+		print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], 's.email', '', $param, '', $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);
 	}
@@ -1769,6 +1786,7 @@ if ($resql) {
 			$companystatic->zip = $obj->zip;
 			$companystatic->town = $obj->town;
 			$companystatic->country_code = $obj->country_code;
+			$companystatic->email = $obj->email;
 
 			$projectstatic->id = $obj->project_id;
 			$projectstatic->ref = $obj->project_ref;
@@ -1985,6 +2003,15 @@ if ($resql) {
 					$totalarray['nbfield']++;
 				}
 			}
+			// Email
+			if (!empty($arrayfields['s.email']['checked'])) {
+				print '<td class="nowraponall">';
+				print dol_escape_htmltag($obj->email);
+				print '</td>';
+				if (!$i) {
+					$totalarray['nbfield']++;
+				}
+			}
 			// Type ent
 			if (!empty($arrayfields['typent.code']['checked'])) {
 				print '<td class="center">';