/** * get_company_search * * @return string XML representation of the search results (list of companies ids that match the query) */ function get_company_search() { // the obm var nams and the search parameters names may be different $replacement = array('name' => 'name', 'number'=>'number', 'phone'=>'phone', 'zip'=>'zip', 'town'=>'town', 'country'=>'country', 'type'=>'type', 'activity'=>'activity', 'naf'=>'naf', 'datasource'=>'datasource', 'market'=>'market', 'date_after'=>'date_after', 'date_before'=>'date_before' ); $field_list = array('company_id' => 'company_id', 'company_name' => 'company_name', 'company_number' => 'company_number', 'company_nafcode_id' => 'company_isin', 'company_address1' => 'company_address1', 'company_address2' => 'company_address2', 'company_address3' => 'company_address3', 'company_town' => 'company_town', 'company_zipcode' => 'company_zipcode', 'country_name' => 'company_country', 'company_phone' => 'company_phone', 'company_fax' => 'company_fax', 'company_email' => 'company_email', 'company_web' => 'company_web' ); $get=array(); $root_node='listing'; $multi_search = false; $require_fields = array(); //permet de récupérer les champs qu'il faut affiché $field_list = prepare_field_list($_GET,$field_list); foreach($replacement as $key => $value){ if(isset($_GET[$value])){ $get[$key]=$_GET[$value]; } } //recupère tous les critères pour le recherche multiple $multi_search = search_multicritere($get,&$multicritere,&$champ); $datas = array(); //Si c'est une recherche multicritere on recupere les informations //pour chaque critère if($multi_search){ $root_node='multisearch'; foreach($multicritere as $val){ //a chaque critère on modifie le champ $get[$champ]=$val; $data = get_company_mono_search($get,$field_list); if(!empty($data)){ //on fusionne les information que l'on as déjà avec les //nouvelles pour evité les doublons $datas=array_merge($datas,$data); } } } else { $field_list=array('company_id' => 'company_id'); $datas=get_company_mono_search($get,$field_list); } // if no datas, return if (count($datas) == 0) { return ; } return create_xml($datas,$root_node,'company',$multi_search); }
/** * get_contact_search * * @return string XML representation of the search results (list of contact ids that match the query) */ function get_contact_search() { // the obm var nams and the search parameters names may be different $replacement = array('fname' => 'firstname', 'lname' => 'lastname', 'privacy' => 'privacy', 'number'=>'number', 'phone'=>'phone', 'email'=>'email', 'company'=>'company', 'zip'=>'zip', 'town'=>'town', 'country'=>'country', 'datasource'=>'datasource', 'function'=>'function', 'title'=>'title', 'market'=>'market', 'date_field'=>'date_type', 'date_after'=>'date_after', 'date_before'=>'date_before', ); $field_list = array('contact_id' => 'contact_id', 'contactfunction_label' => 'contact_function', 'contact_firstname' => 'contact_firstname', 'contact_lastname' => 'contact_lastname', 'kind_minilabel' => 'contact_genre', 'contact_title' => 'contact_title', 'contact_service' => 'contact_office', 'contact_address1' => 'contact_address1', 'contact_address2' => 'contact_address2', 'contact_address3' => 'contact_address3', 'company_town' => 'company_town', 'company_zipcode' => 'company_zipcode', 'company_country_name' => 'company_country', 'company_phone' => 'company_phone', 'company_fax' => 'company_fax', 'contact_email' => 'contact_email' ); $get=array(); $root_node='listing'; $multi_search = false; $require_fields = array(); $field_list = prepare_field_list($_GET,$field_list); foreach($replacement as $key => $value){ if(isset($_GET[$value])){ $get[$key]=$_GET[$value]; } } $multi_search = search_multicritere($get,&$multicritere,&$champ); $datas = array(); if($multi_search){ $root_node='multisearch'; foreach($multicritere as $val){ $get[$champ]=$val; $data = get_contact_mono_search($get,$field_list); if(!empty($data)){ $datas=array_merge($datas,$data); } } } else { $field_list=array('contact_id' => 'contact_id'); $datas=get_contact_mono_search($get,$field_list); } // if no datas, return if (count($datas) == 0) { return ; } return create_xml($datas,$root_node,'contact',$multi_search); }