diff --git a/ChangeLog b/ChangeLog index 10ef7d57e64..bc94a498d33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,7 @@ For users: - Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count - New : Add pdf link into supplier invoice list and supplier order list - New : Genrate auto the PDF for supplier invoice +- New : Add category into filter webservice thirdparty method getListOfThirdParties For translators: - Qual: Normalized sort order of all languages files with english reference files. diff --git a/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN b/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN index 84fb93bd732..3260549b712 100755 --- a/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN +++ b/htdocs/webservices/demo_wsclient_thirdparty.php-NORUN @@ -32,12 +32,14 @@ $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php'; $WS_METHOD_GETTHIRDSPARTY = 'getThirdParty'; $WS_METHOD_CREATETHIRDSPARTY = 'createThirdParty'; $WS_METHOD_UPDATETHIRDSPARTY = 'updateThirdParty'; +$WS_METHOD_GETTHIRDSPARTYLIST = 'getListOfThirdParties'; $ns='http://www.dolibarr.org/ns/'; //Chosse action to do //$action='get'; -$action='create'; +//$action='create'; //$action='update'; +$action='getList'; // Set the WebService URL @@ -75,6 +77,24 @@ if ($action=='get') } } +// Test URL +if ($action=='getList') +{ + $filterthirdparty=array('category'=>'3'); + $parameters = array('authentication'=>$authentication,$filterthirdparty); + dol_syslog("Call method ".$WS_METHOD_GETTHIRDSPARTYLIST); + $result = $soapclient->call($WS_METHOD_GETTHIRDSPARTYLIST,$parameters,$ns,''); + if (! $result) + { + print $soapclient->error_str; + print "
\n\n"; + print $soapclient->request; + print "
\n\n"; + print $soapclient->response; + exit; + } +} + // Test URL if ($action=='create') { diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index a8ef028a9c8..2067ed5f63d 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -160,7 +160,8 @@ $server->wsdl->addComplexType( array( //'limit' => array('name'=>'limit','type'=>'xsd:string'), 'client' => array('name'=>'client','type'=>'xsd:string'), - 'supplier' => array('name'=>'supplier','type'=>'xsd:string') + 'supplier' => array('name'=>'supplier','type'=>'xsd:string'), + 'category' => array('name'=>'category','type'=>'xsd:string') ) ); @@ -640,14 +641,17 @@ function getListOfThirdParties($authentication,$filterthirdparty) if (! $error) { - $sql ="SELECT rowid, nom as ref, ref_ext"; - $sql.=" FROM ".MAIN_DB_PREFIX."societe"; + $sql ="SELECT s.rowid, s.nom as ref, s.ref_ext, s.address, s.zip, s.town, p.libelle as country, s.phone, s.fax, s.url"; + $sql.=" FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON s.fk_pays = p.rowid'; $sql.=" WHERE entity=".$conf->entity; foreach($filterthirdparty as $key => $val) { - if ($key == 'client' && $val != '') $sql.=" AND client = ".$db->escape($val); - if ($key == 'supplier' && $val != '') $sql.=" AND fournisseur = ".$db->escape($val); + if ($key == 'client' && $val != '') $sql.=" AND s.client = ".$db->escape($val); + if ($key == 'supplier' && $val != '') $sql.=" AND s.ournisseur = ".$db->escape($val); + if ($key == 'category' && $val != '') $sql.=" AND s.rowid IN (SELECT fk_societe FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") "; } + dol_syslog("Function: getListOfThirdParties sql=".$sql); $resql=$db->query($sql); if ($resql) { @@ -657,7 +661,17 @@ function getListOfThirdParties($authentication,$filterthirdparty) while ($i < $num) { $obj=$db->fetch_object($resql); - $arraythirdparties[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext); + $arraythirdparties[]=array('id'=>$obj->rowid, + 'ref'=>$obj->ref, + 'ref_ext'=>$obj->ref_ext, + 'adress'=>$obj->adress, + 'zip'=>$obj->zip, + 'town'=>$obj->town, + 'country'=>$obj->country, + 'phone'=>$obj->phone, + 'fax'=>$obj->fax, + 'url'=>$obj->url + ); $i++; } }