Add category into filter into webservice thirdparty method

getListOfThirdParties
This commit is contained in:
Florian Henry 2013-08-15 10:39:59 +02:00
parent fa5f09d6e0
commit 472d218372
3 changed files with 42 additions and 7 deletions

View File

@ -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.

View File

@ -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 "<br>\n\n";
print $soapclient->request;
print "<br>\n\n";
print $soapclient->response;
exit;
}
}
// Test URL
if ($action=='create')
{

View File

@ -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++;
}
}