Merge pull request #1224 from jfefe/fix_ws_invoice

Fix ws invoice
This commit is contained in:
Laurent Destailleur 2013-09-09 08:53:00 -07:00
commit 2ec45acbbd

View File

@ -330,9 +330,6 @@ function getInvoice($authentication,$id='',$ref='',$ref_ext='')
'close_code' => $invoice->close_code?$invoice->close_code:'',
'close_note' => $invoice->close_note?$invoice->close_note:'',
'lines' => $linesresp
// 'lines' => array('0'=>array('id'=>222,'type'=>1),
// '1'=>array('id'=>333,'type'=>1))
));
}
else
@ -393,10 +390,6 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
$sql.='SELECT f.rowid as facid, facnumber as ref, ref_ext, type, fk_statut as status, total_ttc, total, tva';
$sql.=' FROM '.MAIN_DB_PREFIX.'facture as f';
//$sql.=', '.MAIN_DB_PREFIX.'societe as s';
//$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
//$sql.=" WHERE f.fk_soc = s.rowid AND nom = '".$db->escape($idthirdparty)."'";
$sql.=" WHERE f.entity = ".$conf->entity;
if ($idthirdparty != 'all' ) $sql.=" AND f.fk_soc = ".$db->escape($idthirdparty);
@ -414,12 +407,14 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
$invoice->fetch($obj->facid);
// Sécurité pour utilisateur externe
if( $socid && ( $socid != $order->socid) )
if( $socid && ( $socid != $invoice->socid) )
{
$error++;
$errorcode='PERMISSION_DENIED'; $errorlabel=$order->socid.' User does not have permission for this request';
$errorcode='PERMISSION_DENIED'; $errorlabel=$invoice->socid.' User does not have permission for this request';
}
if(!$error)
{
// Define lines of invoice
$linesresp=array();
foreach($invoice->lines as $line)
@ -461,6 +456,7 @@ function getInvoicesForThirdParty($authentication,$idthirdparty)
'close_note' => $invoice->close_note?$invoice->close_note:'',
'lines' => $linesresp
);
}
$i++;
}