我想制作详细的交易清单,一切正常,除非在1个交易中买2个不同的项目,它打印1个细节项目。我已经确定查询结果为2项。
这是打印详细内容的代码。
async makeRemoteRequestNotification() {
var backapi = api.Backend_API();
let userId = await AsyncStorage.getItem("userid");
fetch(backapi + "event/notification/" + userId, {
method: "GET",
}).then((response) => response.json())
.then((data) => {
for(let i in data){
fetch(backapi+"event/eventname/"+data[i].event_id,{
method:'GET',
}).then((response)=>response.json())
.then((data)=>{
this.state.data.push(data)
console.log("notification event",this.state.data);
})
console.log("created_by",data[i].created_by);
fetch(backapi+"user/getUserById"+data[i].created_by,{
method:'GET'
}).then((response)=>response.json())
.then((data)=>{
console.log("username",data);
})
}
// this.state.data=data;
console.log("clint",this.state.data);
})
};
这是查询功能:
$q_invo = get_detail_transaction($r_invoice['transaction_id']);
$no = 1;
$hh = 5;
while ($r_invo = mysql_fetch_array($q_invo)) {
$pdf->Cell(10, $hh+5, $no, 1, 0, 'C');
$pdf->Cell(40, $hh+5, $r_invo['kode_barang'], 1, 0, 'C');
$pdf->Cell(45, $hh+5, $r_invo['item_name'], 1, 0, 'C');
$pdf->Cell(20, $hh+5, $r_invo['transaction_detail_qty_real'].
'('.$r_invo['unit_utama_name'].')', 1, 0, 'C');
$unit_id_utama = get_unit_id($r_invo['item_id']);
$pdf->Cell(30, $hh+5, konversi_total_jumlah($unit_id_utama,
$r_invo['item_id'],$r_invo['transaction_detail_qty_real'],
$r_invo['transaction_detail_unit']), 1, 0, 'C');
$item_id = $r_invo['item_id'];
$where_item_id = "WHERE item_id = '$item_id' AND transaction_id = '$transaction_id'";
$q_item_keterangan_details = select_config('transaction_details_item' ,$where_item_id);
while ($r_item_keterangan_details = mysql_fetch_array($q_item_keterangan_details)) {
$keterangan_item = $r_item_keterangan_details['keterangan_item'];
$where_keterangan_item = "WHERE item_keterangan_details_id = '$keterangan_item'";
$q_item_keterangan_details_id = select_config_by('item_keterangan_details',
'keterangan_details', $where_keterangan_item);
}
$pdf->Cell(55, $hh+5,$q_item_keterangan_details_id, 1, 0,'C');
$pdf->Cell(40, $hh+5, format_rupiah($r_invo['transaction_detail_price']), 1, 0, 'R');
$pdf->Cell(50, $hh+5, format_rupiah($r_invo['transaction_detail_price']*$r_invo['transaction_detail_qty']), 1, 0, 'R');
$no++;
$total_jml = $total_jml + $r_invo['transaction_detail_qty_real'];
$total_berat = $total_berat + $r_invo['item_berat'];
$hh = $hh + 5;
}
上面的查询给出了2行的结果。我已经测试过了。