function viewpo($state, $no, $staffno) { $finalPoNo = getPoNo($no); $out = ""; $out .= "<input type=\"button\" value=\"重印PO\" class=\"finIncel\" onclick=\"printPO(" . $no . ");\"/>"; $out .= "<table border=0 id=editTable width=100%><tbody><tr><td>購貨單編號</td><td colspan=1><input type=text id=editPoNo name=editPoNo size=10 disabled value=" . $finalPoNo . "></td></tr>"; $out .= "<tr><td>新增者(員工編號)</td><td colspan=1><input type=text id=editStaffNo name=editStaffNo size=10 disabled value=" . $staffno . "></td></tr><tr><td colspan=3>手提電話</td></tr>"; $out .= "<tr><td colspan=3><table border=1 id=editPhoneDetail width=100%><tbody><tr><td width=13%>貨品編號</td><td width=60%>貨品名稱</td><td width=5%>數量</td><td width=8%>成本</td></tr>"; $result = mysql_query("select * from po,podetail,phonetype where po.po_no = " . $no . " and po.po_no = podetail.po_no and phonetype.phoneType_no = podetail.phonetype_no"); while ($row = mysql_fetch_array($result)) { $out .= "<tr><td>" . $row['phonetype_id'] . "</td><td>" . $row['phone_name'] . "</td><td>" . $row['qty'] . "</td><td>" . $row['cost'] . "</td></tr>"; } $out .= "</tbody></table></td></tr>"; $result = mysql_query("select * from po,podetail,accessories where po.po_no = " . $no . " and po.po_no = podetail.po_no and podetail.acc_no = accessories.acc_no"); $out .= "<tr><td colspan=3>配件</td></tr>"; $out .= "<tr><td colspan=3><table border=1 id=editAssDetail width=100%><tbody><tr><td width=13%>貨品編號</td><td width=60%>貨品名稱</td><td width=5%>數量</td><td width=8%>成本</td></tr>"; while ($row = mysql_fetch_array($result)) { $out .= "<tr><td>" . $row['acc_id'] . "</td><td>" . $row['accName'] . "</td><td>" . $row['qty'] . "</td><td>" . $row['cost'] . "</td></tr>"; } $out .= "</tbody></table></td></tr>"; $out .= "</tbody></table>"; return urlencode(utf8_encode($out)); }
function get_stockin_report() { global $db; echo '<table border="0" class="sales_report" style="width:100%" >' . '<thead>' . '<th style="width: 90px">入貨日期</th>' . '<th>單號</th>' . '<th>產品名稱</th>' . '<th style="width: 70px">數量</th>'; if (check_is_office()) { echo '<th style="width: 70px">入貨金額</th>' . '<th style="width: 70px">總金額</th>' . '<th style="width: 70px">供應商編號</th>'; } echo '<th style="width: 70px">貨倉位置</th>' . '<th>開單員工</td>'; if (check_is_office()) { echo '<th>PO No.</td>'; } echo '</thead><tbody>'; $DATE2 = date("Y-m-d"); $DATE2_s1 = explode('-', $DATE2); //cut the date into array $sql1 = "select sinno_ref_no, staff_id\r\n\t\t\t from sinno_ref \r\n\t\t\t LEFT JOIN staff ON sinno_ref.createBy=staff.staff_no"; if (isset($_POST['datepicker_from']) && isset($_POST['datepicker_to'])) { $startDay = $_POST['datepicker_from']; $endDay = $_POST['datepicker_to']; $startDay_s1 = explode('-', $startDay); //cut the date into array $endDay_s1 = explode('-', $endDay); //cut the date into array $sql1 .= " where year(createDate) >= {$startDay_s1['0']}\r\n\t\t\t\t\t\tand year(createDate) <= {$endDay_s1['0']}\r\n\t\t\t\t\t\tAND month(createDate) >= {$startDay_s1['1']}\r\n\t\t\t\t\t\tAND month(createDate) >= {$endDay_s1['1']}\r\n\t\t\t\t\t\tAND day(createDate) >= {$startDay_s1['2']} \r\n\t\t\t\t\t\tAND day(createDate) <= {$endDay_s1['2']}"; } else { if (isset($_POST['supplier']) || isset($_POST['accMobi_list']) || isset($_POST['product_id']) || isset($_POST['staff_list'])) { $sql1 .= ""; } else { $sql1 .= " where year(createDate) = {$DATE2_s1['0']} AND month(createDate) = {$DATE2_s1['1']} AND day(createDate) = {$DATE2_s1['2']}"; } } if (isset($_POST['staff_list'])) { $staff_list = $_POST['staff_list']; $sql1 .= " where staff_no in ({$staff_list})"; } $result = $db->query($sql1); if ($result) { while ($row1 = $db->fetch_array($result)) { $sinno_ref_no = $row1['sinno_ref_no']; $finalsinno_ref_no = getStockIn($sinno_ref_no); $sql2 = "select * \r\n\t\t\t\t\t\tfrom stockin st\r\n\t\t\t\t\t\tLEFT JOIN accessories ON st.acc_no=accessories.acc_no\r\n\t\t\t\t\t\tLEFT JOIN retailShop AS rt ON st.retailShop_no=rt.retailShop_no\r\n\t\t\t\t\t\tLEFT JOIN staff ON st.staff_no=staff.staff_no\r\n\t\t\t\t\t\tLEFT JOIN ( po left join podetail as pod ON po.po_no=pod.po_no\r\n\t\t\t\t\t\t\t\t\t\tleft join supplier as sp ON po.supplier_no=sp.supplier_no)\r\n\t\t\t\t\t\t\t\t\t\tON st.poDetail_no = pod.poDetail_no\r\n\t\t\t\t\t\twhere sinno_ref_no={$sinno_ref_no}"; if (check_is_office()) { } else { $sql2 .= " and st.retailShop_no in (" . get_retail_no() . ")"; } if (isset($_POST['supplier'])) { $supplier = $_POST['supplier']; $sql2 .= " and po.supplier_no in ({$supplier})"; } if (isset($_POST['accMobi_list'])) { $accMobi_list = $_POST['accMobi_list']; if ($accMobi_list == 'mobile') { $sql2 .= " and accessories.accType_no = 'dddd'"; } else { $sql2 .= " and accessories.accType_no = {$accMobi_list}"; } } if (isset($_POST['product_id'])) { $product_id = $_POST['product_id']; $sql2 .= " and accessories.acc_id = '{$product_id}'"; } //echo $sql2; $result2 = $db->query($sql2); $num_rows = $db->num_rows($db->select($sql2)); $total_qty = 0; $all_totaliprice = 0; if ($result2 && $num_rows > 0) { while ($row2 = $db->fetch_array($result2)) { $rec_qty = $row2['rec_qty']; $iprice = $row2['iprice']; $totaliprice = $rec_qty * $iprice; $all_totaliprice = $all_totaliprice + $iprice; $tempPoNo = $row2['po_no']; $finalPoNo = getPoNo($tempPoNo); $DATE1 = $row2['rec_date']; $DATE1_s1 = explode(' ', $DATE1); //cut out the date (without time) into array $total_qty = $total_qty + $row2['rec_qty']; echo '<tr><td>' . $DATE1_s1[0] . '</td>'; echo '<td>' . $finalsinno_ref_no . '</td>'; // echo '<td>'.$row2['acc_id'].'</td>'; echo '<td style="padding:0 8px 0 8px; text-align:left;">' . $row2['accName'] . '</td>'; echo '<td>' . $row2['rec_qty'] . '</td>'; if (check_is_office()) { echo '<td>$' . number_format($iprice, 1, '.', ',') . '</td>' . '<td>$' . number_format($totaliprice, 1, '.', ',') . '</td>' . '<td>' . $row2['supplier_id'] . '</td>'; } echo '<td>' . $row2['retail_id'] . '</td>'; echo '<td>' . $row2['staff_id'] . '</td>'; if (check_is_office()) { echo '<td>' . $finalPoNo . '</td>'; } echo '</tr>'; } echo '<tr style="border-bottom:#0000FF 1px solid;"></tr>'; echo '<tr><td colspan="3" style="text-align:right">Total : </td>' . '<td>' . $total_qty . '</td>'; echo '<td></td>'; if (check_is_office()) { echo '<td>$' . number_format($all_totaliprice, 1, '.', ',') . '</td>'; } echo '</tr><tr style="height:20px"></tr>'; } $sql2 = "select *\r\n\t\t\t\t\t\tfrom phone ph\r\n\t\t\t\t\t\tLEFT JOIN phonetype AS pt ON ph.phoneType_no=pt.phoneType_no\r\n\t\t\t\t\t\tLEFT JOIN retailShop AS rt ON ph.retailShop_no=rt.retailShop_no\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tLEFT JOIN ( po left join podetail as pod ON po.po_no=pod.po_no\r\n\t\t\t\t\t\t\t\t\t\tleft join supplier as sp ON po.supplier_no=sp.supplier_no)\r\n\t\t\t\t\t\t\t\t\t\tON ph.poDetail_no = pod.poDetail_no\r\n\t\t\t\t\t\twhere sinno_ref_no={$sinno_ref_no}"; if (check_is_office()) { } else { $sql2 .= " and ph.retailShop_no in (" . get_retail_no() . ")"; } if (isset($_POST['supplier'])) { $supplier = $_POST['supplier']; $sql2 .= " and po.supplier_no in ({$supplier})"; } if (isset($_POST['accMobi_list'])) { $accMobi_list = $_POST['accMobi_list']; if ($accMobi_list != 'mobile') { $sql2 .= " and ph.phoneType_no = 'ddd'"; } } if (isset($_POST['product_id'])) { $product_id = $_POST['product_id']; $sql2 .= " and phonetype_id = '{$product_id}'"; } $result2 = $db->query($sql2); //$qty=$row2['total_qty']; $num_rows = $db->num_rows($db->select($sql2)); $all_totaliprice = 0; if ($result2 && $num_rows > 0) { while ($row2 = $db->fetch_array($result2)) { //$rec_qty = $row2['total_qty']; $iprice = $row2['cost']; $totaliprice = 1 * $iprice; $all_totaliprice = $all_totaliprice + $iprice; $tempPoNo = $row2['po_no']; $finalPoNo = getPoNo($tempPoNo); $DATE1 = $row2['rec_date']; $DATE1_s1 = explode(' ', $DATE1); //cut out the date (without time) into array //$total_qty=$total_qty+$row2['rec_qty']; $sinno_ref_no = $row1['sinno_ref_no']; $finalsinno_ref_no = getStockIn($sinno_ref_no); echo '<tr><td>' . $DATE1_s1[0] . '</td>'; echo '<td>' . $finalsinno_ref_no . '</td>'; // echo '<td>'.$row2['phonetype_id'].'</td>'; echo '<td style="padding:0 8px 0 8px;text-align:left;">' . $row2['manufacturer'] . ' ' . $row2['phone_name'] . ' (' . $row2['color'] . ') (' . $row2['IMEI'] . ')</td>'; echo '<td>1</td>'; if (check_is_office()) { echo '<td>$' . number_format($iprice, 1, '.', ',') . '</td>' . '<td>$' . number_format($totaliprice, 1, '.', ',') . '</td>' . '<td>' . $row2['supplier_id'] . '</td>'; } if ($row2['retail_id'] == 'Transferring') { echo '<td><div style="background:#B50122;color:#fff;">Transferring</div></td>'; } else { echo '<td>' . $row2['retail_id'] . '</td>'; } echo '<td>' . $row1['staff_id'] . '</td>'; if (check_is_office()) { echo '<td>' . $finalPoNo . '</td>'; } echo '</tr>'; } echo '<tr style="border-bottom:#0000FF 1px solid;"></tr>'; echo '<tr><td colspan="3" style="text-align:right">Total : </td>' . '<td>' . $num_rows . '</td>'; echo '<td></td>'; if (check_is_office()) { echo '<td>$' . number_format($all_totaliprice, 1, '.', ',') . '</td>'; } echo '</tr><tr style="height:20px"></tr>'; } } } echo '</tbody></table>'; }