Advertisement
Guest User

salesReport

a guest
Mar 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.28 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3. include '../../../../DatabaseController/conn.php';
  4.  
  5. $conn = $pdo->open();
  6.  
  7. $stmt = $conn->prepare("SELECT * FROM users
  8. LEFT JOIN user_title ON users.title_id = user_title.title_id
  9. LEFT JOIN user_dept ON users.department_id = user_dept.department_id
  10. LEFT JOIN user_position ON users.position_id = user_position.position_id
  11. WHERE id=:id");
  12. $stmt->execute(['id'=>$_SESSION['user_id']]);
  13.  
  14. $user = $stmt->fetch();
  15.  
  16. $pdo->close();
  17. ?>
  18. <?php
  19. if (!isset($_SESSION['accounting']) || $_SESSION["position"] == null){
  20.  
  21. unset($_SESSION['position']); //Position ID
  22.  
  23. unset($_SESSION['accounting']); //Position
  24.  
  25. $_SESSION['unathorized'] = "We Are Watching You, You've Visiting Unathorized Access..";
  26.  
  27. header('Location: /OneTrinity/');
  28.  
  29. exit();
  30. }
  31. ?>
  32. <html>
  33. <head>
  34. <meta charset="utf-8">
  35. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  36. <title>Sales Report</title>
  37. <style type="text/css">
  38. @font-face {
  39. font-family: 'Franklin Gothic Book'; /*a name to be used later*/
  40. src: url('../../../../Fonts/FranklinGothic.ttf'); /*URL to font*/
  41. }
  42. body {
  43. font-family: Franklin Gothic Book;
  44. }
  45. form {
  46. overflow: hidden;
  47. }
  48. table, th, td {
  49. border: 1px solid black;
  50. }
  51. table tfoot {
  52. display: table-row-group;
  53. }
  54. .address {
  55. font-size: 10pt;
  56. }
  57. .customer-details{
  58. background-color: #0094de;
  59. color: white;
  60. text-align: center;
  61. font-size: 9.7pt;
  62. font-weight: bold;
  63. }
  64. .remarks{
  65. border: 1px solid black;
  66. background-color: black;
  67. color: white;
  68. text-align:center;
  69. font-size: 9.7pt;
  70. padding-top: 7px;
  71. font-weight: bold;
  72. }
  73. .queryResult-CSS {
  74. text-align: center;
  75. }
  76. @page {
  77. size: 14in 8.5in;
  78. height: 356mm;
  79. width: 216mm;
  80. }
  81. @media print {
  82. body {
  83. -webkit-print-color-adjust: exact;
  84. }
  85. .customer-details {
  86. -webkit-print-color-adjust: exact;
  87. }
  88. .remarks{
  89. -webkit-print-color-adjust: exact;
  90. }
  91. }
  92. </style>
  93. </head>
  94. <body>
  95. <div>
  96. <?php
  97. $brand_id = $_POST['show_brand'];
  98. $model_id = $_POST['show_model'];
  99. $container_id = $_POST['show_container'];
  100. // for date purposes
  101. date_default_timezone_set('Asia/Manila');
  102. $date = date('M d, Y g:i:s A');
  103.  
  104. $conn = $pdo->open();
  105.  
  106. try {
  107. $selectModelName = $conn->prepare("SELECT pm.model_name, c.container_number FROM product_model as pm
  108. LEFT JOIN brand as b ON pm.brand_id = b.brand_id
  109. LEFT JOIN product as p on pm.model_id = p.model_id
  110. LEFT JOIN container as c on p.container_id = c.container_id
  111. WHERE pm.model_id = :model_id AND b.brand_id = :brand_id AND c.container_id = :container_id
  112. GROUP BY pm.model_id");
  113. $selectModelName->execute(['model_id'=>$model_id,'brand_id'=>$brand_id, 'container_id'=>$container_id]);
  114. $displayModelName = $selectModelName->fetchAll();
  115.  
  116. foreach ($displayModelName as $data) {
  117. $model_name = $data['model_name'];
  118. $container_number = $data['container_number'];
  119.  
  120. if ($brand_id == "1") {
  121. echo "
  122. <div style='float: left; max-width: 600px;'>
  123. <img src='../../../../styles/brand-logos/trinx-straight.png' style='margin-left:120px;width:200px; height: 200px;'>
  124. <span><p style='font-size: 16pt; margin-left: 100px'>".$model_name."</p></span>
  125. </div>
  126. <div style='float: right;'>
  127. <span class='address'><p>ONE TRINITY CORPORATION</p></span>
  128. <span class='address'><p>HERMOSO COMPOUND DALANDANDAN, VALENZUELA</p></span>
  129. <span class='address'><p>TEL/FAX: +632 292 7071</p></span>
  130. <span class='address'><p>URL: www.trinx.com</p></span>
  131. <span class='address'>
  132. <p>Email:
  133. <span style='color:#0094de;'>philippines@trinx.com</span>
  134. </p>
  135. </span>
  136. <span></span><p style='font-size: 16pt;margin-top: 95.3px;'>".$container_number."</p></span>
  137. <span></span><p style='font-size: 16pt;'>".$date."</p></span>
  138. </div>
  139. ";
  140. } else if ($brand_id == "2") {
  141. echo "
  142. <div style='float: left; max-width: 600px;'>
  143. <img src='../../../../styles/brand-logos/keysto.png' style='margin-left:120px;width:200px; height: 200px;'>
  144. <span><p style='font-size: 16pt; margin-left: 100px'>".$model_name."</p></span>
  145. </div>
  146. <div style='float: right;'>
  147. <span class='address'><p>ONE TRINITY CORPORATION</p></span>
  148. <span class='address'><p>HERMOSO COMPOUND DALANDANDAN, VALENZUELA</p></span>
  149. <span class='address'><p>TEL/FAX: +632 292 7071</p></span>
  150. <span class='address'><p>URL: www.trinx.com</p></span>
  151. <span class='address'>
  152. <p>Email:
  153. <span style='color:#0094de;'>philippines@trinx.com</span>
  154. </p>
  155. </span>
  156. <span></span><p style='font-size: 16pt;margin-top: 95.3px;'>".$container_number."</p></span>
  157. <span></span><p style='font-size: 16pt;'>".$date."</p></span>
  158. </div>
  159. ";
  160. } else if ($brand_id == "3") {
  161. echo "
  162. <div style='float: left; max-width: 600px;'>
  163. <img src='../../../../styles/brand-logos/phantom.png' style='margin-left:120px;width:200px; height: 200px;'>
  164. <span><p style='font-size: 16pt; margin-left: 100px'>".$model_name."</p></span>
  165. </div>
  166. <div style='float: right;'>
  167. <span class='address'><p>ONE TRINITY CORPORATION</p></span>
  168. <span class='address'><p>HERMOSO COMPOUND DALANDANDAN, VALENZUELA</p></span>
  169. <span class='address'><p>TEL/FAX: +632 292 7071</p></span>
  170. <span class='address'><p>URL: www.trinx.com</p></span>
  171. <span class='address'>
  172. <p>Email:
  173. <span style='color:#0094de;'>philippines@trinx.com</span>
  174. </p>
  175. </span>
  176. <span></span><p style='font-size: 16pt;margin-top: 95.3px;'>".$container_number."</p></span>
  177. <span></span><p style='font-size: 16pt;'>".$date."</p></span>
  178. </div>
  179. ";
  180. } else if ($brand_id == "4") {
  181. echo "
  182. <div style='float: left; max-width: 600px;'>
  183. <img src='../../../../styles/brand-logos/concept.png' style='margin-left:120px;width:200px; height: 200px;'>
  184. <span><p style='font-size: 16pt; margin-left: 100px'>".$model_name."</p></span>
  185. </div>
  186. <div style='float: right;'>
  187. <span class='address'><p>ONE TRINITY CORPORATION</p></span>
  188. <span class='address'><p>HERMOSO COMPOUND DALANDANDAN, VALENZUELA</p></span>
  189. <span class='address'><p>TEL/FAX: +632 292 7071</p></span>
  190. <span class='address'><p>URL: www.trinx.com</p></span>
  191. <span class='address'>
  192. <p>Email:
  193. <span style='color:#0094de;'>philippines@trinx.com</span>
  194. </p>
  195. </span>
  196. <span></span><p style='font-size: 16pt;margin-top: 95.3px;'>".$container_number."</p></span>
  197. <span></span><p style='font-size: 16pt;'>".$date."</p></span>
  198. </div>
  199. ";
  200. }
  201. }
  202.  
  203. } catch (PDOEXception $e) {
  204. echo $e->getMessage();
  205. }
  206. $pdo->close();
  207. ?>
  208. </div>
  209. <table style="width:100%" cellspacing="0" cellpadding="0">
  210. <thead>
  211. <tr>
  212. <th class="customer-details" style='text-align:center; vertical-align: top;padding-top: 10px;' rowspan="2">Customer Name</th>
  213. <th class="customer-details" style='text-align:center; vertical-align: top;padding-top: 10px;' rowspan="2">Sold Quantity</th>
  214. <th class="customer-details" style='text-align:center; vertical-align: top;padding-top: 10px;' rowspan="2">Stocked Quantity</th>
  215. <th class="customer-details" style='text-align:center; vertical-align: top;padding-top: 10px;' rowspan="2">Unit Price</th>
  216. <th class="customer-details" style='text-align:center; vertical-align: top;padding-top: 10px;' rowspan="2">Total Price by Brand</th>
  217. <th class="customer-details" style='text-align:center; vertical-align: top;padding-top: 10px;' rowspan="2">Date Delivered</th>
  218. <th class="customer-details" style='text-align:center;vertical-align: top;padding-top: 10px;padding-bottom: 5px;' colspan="5">Remarks</th>
  219. <tr>
  220. <th class="remarks">BANK NAME</th>
  221. <th class="remarks">PAYMENT METHOD</th>
  222. <th class="remarks">CHEQUE NUMBER</th>
  223. <th class="remarks">CHEQUE DATE</th>
  224. <th class="remarks">AMOUNT</th>
  225. </tr>
  226. </tr>
  227. </thead>
  228. <tbody>
  229. <?php
  230. $model_id = $_POST['show_model'];
  231. $container_id = $_POST['show_container'];
  232.  
  233. try {
  234. $total = array(); //Total QTY
  235. $totalPrice = array();
  236. $totalAmount = array();
  237.  
  238. $selectDataToShow = $conn->prepare("
  239. SELECT t.transaction_id,
  240. IFNULL(pay.trans_count, 0) AS trans_count,
  241. IFNULL(pays.multi_count, 0) AS multi_count,
  242. CONCAT(cl.firstName, ' ', cl.lastName) as full, t.transaction_no,
  243. COUNT(p.model_id) as qty, ps.unitPrice, ps.promoPrice, COUNT(p.qr_code) as stock,
  244. SUM(ps.unitPrice) as one, SUM(ps.promoPrice) as two, t.transaction_date, t.skip
  245. FROM transactions as t
  246. LEFT JOIN product_sales as ps ON t.transaction_no = ps.transaction_no
  247. LEFT JOIN product as p ON ps.product_id = p.product_id
  248. LEFT JOIN (
  249. SELECT
  250. COUNT(CASE WHEN pay.transaction_id > 0 THEN 1 END) AS trans_count,pay.transaction_id,pay.payment_id
  251. FROM payments as pay
  252. GROUP BY pay.transaction_id
  253. ) pay
  254. ON pay.transaction_id = t.transaction_id
  255. LEFT JOIN (
  256. SELECT
  257. COUNT(CASE WHEN pays.multi_transaction_id > 0 THEN 1 END) AS multi_count,pays.multi_transaction_id,pays.payment_id
  258. FROM payments as pays
  259. GROUP BY pays.multi_transaction_id
  260. ) pays ON pays.multi_transaction_id = t.multi_transaction_id
  261. LEFT JOIN client as cl ON t.client_id = cl.client_id
  262. WHERE p.prod_active = 1 AND p.prod_status = 1 AND p.prod_owned = 1 AND p.tran_status = 1 AND ps.sales_status = 1
  263. AND p.model_id = :model_id AND p.container_id = :container_id
  264. GROUP BY t.transaction_id");
  265. $selectDataToShow->execute(['model_id'=>$model_id, 'container_id'=>$container_id]);
  266.  
  267. $passContainerData = $selectDataToShow->fetchAll();
  268.  
  269.  
  270. $remarksShow = $conn->prepare("SELECT
  271. t.transaction_id,
  272. payments.payment_id,
  273. payments.payment_method, payments.bank_name, payments.check_no,payments.check_date,
  274. payments.payment_amount
  275. FROM transactions as t
  276. LEFT JOIN product_sales as ps ON t.transaction_no = ps.transaction_no
  277. LEFT JOIN product as p ON ps.product_id = p.product_id
  278. LEFT JOIN (
  279. SELECT pay.transaction_id,pay.multi_transaction_id,pay.payment_id, pay.payment_method, pay.bank_name, pay.check_no, pay.check_date, pay.payment_amount
  280. FROM payments as pay
  281. ) payments ON (CASE payments.transaction_id WHEN 0
  282. THEN payments.multi_transaction_id = t.multi_transaction_id
  283. ELSE payments.transaction_id = t.transaction_id
  284. END)
  285. LEFT JOIN client as cl ON t.client_id = cl.client_id
  286. WHERE p.prod_active = 1 AND p.prod_status = 1 AND p.prod_owned = 1 AND p.tran_status = 1 AND ps.sales_status = 1
  287. AND p.model_id = :model_id AND p.container_id = :container_id
  288. GROUP by t.transaction_id,payments.payment_id");
  289.  
  290. $remarksShow->execute(['model_id'=>$model_id, 'container_id'=>$container_id]);
  291.  
  292. $remarks = $remarksShow->fetchAll();
  293.  
  294. foreach ($passContainerData as $data){
  295. $stock = $data['stock'];
  296. $total[] = $stock;
  297. }
  298.  
  299. // count array to use for looping
  300. $count_total_elements = count($total);
  301. //get the sum of the array to use as first array element
  302. $total_qty = array_sum($total);
  303.  
  304. $pass_array_value = array(); //Index Stocked QTY
  305.  
  306. $pass_array_value[0]["stocked_qty"] = $total_qty;
  307.  
  308. $array_def_qty = array($total_qty);
  309. // array where new elements will be pass to
  310.  
  311. for ($i = 0, $j = 0, $k = 1; $i < $count_total_elements; $i++, $j++, $k++) {
  312.  
  313. $new_array_element[$i] = $array_def_qty[$j] - $total[$i];
  314.  
  315. array_push($array_def_qty, $new_array_element[$i]);
  316.  
  317. $pass_array_value[$k]["stocked_qty"] = $new_array_element[$i];
  318. }
  319.  
  320. //get the last array value
  321. $last_array_element = array_pop($array_def_qty);
  322.  
  323. $resultArrayQTy = array();
  324.  
  325. foreach ($passContainerData as $k => $v) {
  326. $resultArrayQTy[$k] = array_merge($passContainerData[$k], $pass_array_value[$k]);
  327. }
  328.  
  329. $j = 0; // Iniatiate Iteration
  330.  
  331. // echo '<pre>';
  332. // print_r($remarks);
  333. // echo '</pre>';
  334.  
  335. foreach ($resultArrayQTy as $data)
  336. {
  337.  
  338. $count = $data["trans_count"];
  339.  
  340. $multi_trans_count = $data["multi_count"];
  341.  
  342. if ($count >= 1 && $multi_trans_count == 0)
  343. {
  344. for($i = 1; $i <= $count; $i++, $j++)
  345. {
  346. if ($i == 1)
  347. {
  348. echo '<tr>';
  349. echo '<td class="queryResult-CSS">'.$data["full"].'</td>';
  350. echo '<td class="queryResult-CSS">'.$data["qty"].' PC/s</td>';
  351. echo '<td class="queryResult-CSS">'.$data["stocked_qty"].' PC/s</td>';
  352. if($data['two'] > "0.00"){
  353. $totalPrice[] = $data['two'];
  354. echo '<td class="queryResult-CSS">₱'.number_format($data["promoPrice"], 2).'</td>';
  355. echo '<td class="queryResult-CSS">₱'.number_format($data["two"], 2).'</td>';
  356. }
  357. else
  358. {
  359. $totalPrice[] = $data['one'];
  360. echo '<td class="queryResult-CSS">₱'.number_format($data["unitPrice"], 2).'</td>';
  361. echo '<td class="queryResult-CSS">₱'.number_format($data["one"], 2).'</td>';
  362. }
  363. echo '<td class="queryResult-CSS">'.$data["transaction_date"].'</td>';
  364. if($data["transaction_id"] == $remarks[$j]["transaction_id"]){
  365. if($remarks[$j]["bank_name"] = " "){
  366. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  367. }
  368. else{
  369. echo '<td class="queryResult-CSS">'.$remarks[$j]["bank_name"].'</td>';
  370. }
  371. if($remarks[$j]["payment_method"] == '1')
  372. {
  373. echo '<td class="queryResult-CSS">'."CASH".'</td>';
  374. }
  375. elseif ($remarks[$j]["payment_method"] == '2'){
  376. echo '<td class="queryResult-CSS">'."ONLINE CASH".'</td>';
  377. }
  378. elseif ($remarks[$j]["payment_method"] == '3'){
  379. echo '<td class="queryResult-CSS">'."CHEQUE".'</td>';
  380. }
  381. else
  382. {
  383. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  384. }
  385. if ($remarks[$j]["check_no"] == "")
  386. {
  387. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  388. }
  389. else
  390. {
  391. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_no"].'</td>';
  392.  
  393. }
  394.  
  395. if ($remarks[$j]["check_date"] == "0000-00-00")
  396. {
  397. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  398. }
  399. else
  400. {
  401. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_date"].'</td>';
  402.  
  403. }
  404. if ($remarks[$j]["payment_amount"] == "")
  405. {
  406. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  407. }
  408. else{
  409. echo '<td class="queryResult-CSS">₱'.number_format($remarks[$j]["payment_amount"], 2).'</td>';
  410. }
  411. }
  412. }
  413. else
  414. {
  415. echo '<tr>';
  416. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  417. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  418. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  419. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  420. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  421. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  422. if($data["transaction_id"] == $remarks[$j]["transaction_id"]){
  423. if($remarks[$i]["bank_name"] = " "){
  424. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  425. }
  426. else{
  427. echo '<td class="queryResult-CSS">'.$remarks[$j]["bank_name"].'</td>';
  428. }
  429. if($remarks[$j]["payment_method"] == '1')
  430. {
  431. echo '<td class="queryResult-CSS">'."CASH".'</td>';
  432. }
  433. elseif ($remarks[$j]["payment_method"] == '2'){
  434. echo '<td class="queryResult-CSS">'."ONLINE CASH".'</td>';
  435. }
  436. elseif ($remarks[$j]["payment_method"] == '3'){
  437. echo '<td class="queryResult-CSS">'."CHEQUE".'</td>';
  438. }
  439. else
  440. {
  441. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  442. }
  443.  
  444.  
  445. if ($remarks[$j]["check_no"] == "")
  446. {
  447. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  448. }
  449. else
  450. {
  451. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_no"].'</td>';
  452.  
  453. }
  454.  
  455. if ($remarks[$j]["check_date"] == "0000-00-00" || $remarks[$j]["check_date"] == "")
  456. {
  457. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  458. }
  459. else
  460. {
  461. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_date"].'</td>';
  462.  
  463. }
  464. if ($remarks[$j]["payment_amount"] == "")
  465. {
  466. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  467. }
  468. else{
  469. echo '<td class="queryResult-CSS">₱'.number_format($remarks[$j]["payment_amount"], 2).'</td>';
  470. }
  471. }
  472. }
  473. }
  474. }
  475. elseif ($count == 0 && $multi_trans_count == 0){
  476. for($i = 0; $i <= 0; $i++, $j++)
  477. {
  478. if ($i == 0)
  479. {
  480. echo '<tr>';
  481. echo '<td class="queryResult-CSS">'.$data["full"].'</td>';
  482. echo '<td class="queryResult-CSS">'.$data["qty"].' PC/s</td>';
  483. echo '<td class="queryResult-CSS">'.$data["stocked_qty"].' PC/s</td>';
  484. if($data['two'] > "0.00"){
  485. $totalPrice[] = $data['two'];
  486. echo '<td class="queryResult-CSS">₱'.number_format($data["promoPrice"], 2).'</td>';
  487. echo '<td class="queryResult-CSS">₱'.number_format($data["two"], 2).'</td>';
  488. }
  489. else
  490. {
  491. $totalPrice[] = $data['one'];
  492. echo '<td class="queryResult-CSS">₱'.number_format($data["unitPrice"], 2).'</td>';
  493. echo '<td class="queryResult-CSS">₱'.number_format($data["one"], 2).'</td>';
  494. }
  495. echo '<td class="queryResult-CSS">'.$data["transaction_date"].'</td>';
  496. if($data["transaction_id"] == $remarks[$j]["transaction_id"])
  497. {
  498. if($remarks[$j]["bank_name"] = " "){
  499. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  500. }
  501. else{
  502. echo '<td class="queryResult-CSS">'.$remarks[$j]["bank_name"].'</td>';
  503. }
  504. if($remarks[$j]["payment_method"] == '1')
  505. {
  506. echo '<td class="queryResult-CSS">'."CASH".'</td>';
  507. }
  508. elseif ($remarks[$j]["payment_method"] == '2'){
  509. echo '<td class="queryResult-CSS">'."ONLINE CASH".'</td>';
  510. }
  511. elseif ($remarks[$j]["payment_method"] == '3'){
  512. echo '<td class="queryResult-CSS">'."CHEQUE".'</td>';
  513. }
  514. else
  515. {
  516. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  517. }
  518. if ($remarks[$j]["check_no"] == "")
  519. {
  520. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  521. }
  522. else
  523. {
  524. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_no"].'</td>';
  525.  
  526. }
  527.  
  528. if ($remarks[$j]["check_date"] == "0000-00-00" || $remarks[$j]["check_date"] == "")
  529. {
  530. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  531. }
  532. else
  533. {
  534. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_date"].'</td>';
  535.  
  536. }
  537. if ($remarks[$j]["payment_amount"] == "")
  538. {
  539. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  540. }
  541. else{
  542. echo '<td class="queryResult-CSS">₱'.number_format($remarks[$j]["payment_amount"], 2).'</td>';
  543. }
  544. }
  545. }
  546. }
  547. }
  548. elseif ($multi_trans_count > 0)
  549. {
  550. for($i = 1; $i <= $multi_trans_count; $i++, $j++)
  551. {
  552. if ($i == 1)
  553. {
  554. echo '<tr>';
  555. echo '<td class="queryResult-CSS">'.$data["full"].'</td>';
  556. echo '<td class="queryResult-CSS">'.$data["qty"].' PC/s</td>';
  557. echo '<td class="queryResult-CSS">'.$data["stocked_qty"].' PC/s</td>';
  558. if($data['two'] > "0.00"){
  559. $totalPrice[] = $data['two'];
  560. echo '<td class="queryResult-CSS">₱'.number_format($data["promoPrice"], 2).'</td>';
  561. echo '<td class="queryResult-CSS">₱'.number_format($data["two"], 2).'</td>';
  562. }
  563. else
  564. {
  565. $totalPrice[] = $data['one'];
  566. echo '<td class="queryResult-CSS">₱'.number_format($data["unitPrice"], 2).'</td>';
  567. echo '<td class="queryResult-CSS">₱'.number_format($data["one"], 2).'</td>';
  568. }
  569. echo '<td class="queryResult-CSS">'.$data["transaction_date"].'</td>';
  570. if($data["transaction_id"] == $remarks[$j]["transaction_id"]){
  571. if($remarks[$j]["bank_name"] = " "){
  572. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  573. }
  574. else{
  575. echo '<td class="queryResult-CSS">'.$remarks[$j]["bank_name"].'</td>';
  576. }
  577. if($remarks[$j]["payment_method"] == '1')
  578. {
  579. echo '<td class="queryResult-CSS">'."CASH".'</td>';
  580. }
  581. elseif ($remarks[$j]["payment_method"] == '2'){
  582. echo '<td class="queryResult-CSS">'."ONLINE CASH".'</td>';
  583. }
  584. elseif ($remarks[$j]["payment_method"] == '3'){
  585. echo '<td class="queryResult-CSS">'."CHEQUE".'</td>';
  586. }
  587. else
  588. {
  589. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  590. }
  591. if ($remarks[$j]["check_no"] == "")
  592. {
  593. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  594. }
  595. else
  596. {
  597. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_no"].'</td>';
  598.  
  599. }
  600.  
  601. if ($remarks[$j]["check_date"] == "0000-00-00" || $remarks[$j]["check_date"] == "")
  602. {
  603. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  604. }
  605. else
  606. {
  607. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_date"].'</td>';
  608.  
  609. }
  610. if ($remarks[$j]["payment_amount"] == "")
  611. {
  612. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  613. }
  614. else{
  615. echo '<td class="queryResult-CSS">₱'.number_format($remarks[$j]["payment_amount"], 2).'</td>';
  616. }
  617. }
  618. }
  619. else
  620. {
  621. echo '<tr>';
  622. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  623. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  624. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  625. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  626. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  627. echo '<td class="queryResult-CSS">'."- - - - - - - - -".'</td>';
  628. if($data["transaction_id"] == $remarks[$j]["transaction_id"]){
  629. if($remarks[$i]["bank_name"] = " "){
  630. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  631. }
  632. else{
  633. echo '<td class="queryResult-CSS">'.$remarks[$j]["bank_name"].'</td>';
  634. }
  635. if($remarks[$j]["payment_method"] == '1')
  636. {
  637. echo '<td class="queryResult-CSS">'."CASH".'</td>';
  638. }
  639. elseif ($remarks[$j]["payment_method"] == '2'){
  640. echo '<td class="queryResult-CSS">'."ONLINE CASH".'</td>';
  641. }
  642. elseif ($remarks[$j]["payment_method"] == '3'){
  643. echo '<td class="queryResult-CSS">'."CHEQUE".'</td>';
  644. }
  645. else
  646. {
  647. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  648. }
  649.  
  650.  
  651. if ($remarks[$j]["check_no"] == "")
  652. {
  653. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  654. }
  655. else
  656. {
  657. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_no"].'</td>';
  658.  
  659. }
  660.  
  661. if ($remarks[$j]["check_date"] == "0000-00-00" || $remarks[$j]["check_date"] == "")
  662. {
  663. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  664. }
  665. else
  666. {
  667. echo '<td class="queryResult-CSS">'.$remarks[$j]["check_date"].'</td>';
  668.  
  669. }
  670. if ($remarks[$j]["payment_amount"] == "")
  671. {
  672. echo '<td class="queryResult-CSS">'."N/A".'</td>';
  673. }
  674. else{
  675. echo '<td class="queryResult-CSS">₱'.number_format($remarks[$j]["payment_amount"], 2).'</td>';
  676. }
  677. }
  678. }
  679. }
  680. }
  681. }
  682. // echo $j;
  683. //count array to use for looping
  684. $count_total_elements = count($total);
  685. //get the sum of the array to use as first array element
  686. $total_qty = array_sum($total);
  687. //array where new elements will be pass to
  688. $pass_array_value = array($total_qty);
  689.  
  690. for($i = 0, $j = 0; $i < $count_total_elements; $i++, $j++){
  691. $new_array_element[$i] = $pass_array_value[$j] - $total[$i];
  692. array_push($pass_array_value, $new_array_element[$i]);
  693. }
  694. // $
  695. //get the last array value
  696. $last_array_element = array_pop($pass_array_value);
  697. //total price per brand
  698. $totalPriceByBrand = array_sum($totalPrice);
  699. echo "</tr> </tbody>";
  700. echo "
  701. <tfoot style='border:none;'>
  702. <tr>
  703. <th colspan='1'>
  704. <th style='text-align:center;'><h5>Closed:</h5></th>
  705. <th style='text-align:center;'><h4 class='red'>".$last_array_element." Qty</h4></th>
  706. <th style='text-align:right;'><h5>Total Price Per Brand:</h5></th>
  707. <th style='text-align:center;'><h4 class='red'>₱".number_format($totalPriceByBrand, 2)."</h4></th>
  708. </th>
  709. </tr>
  710. </tfoot>
  711. ";
  712. }
  713. catch (PDOException $e) {
  714. echo $e->getMessage();
  715. }
  716. ?>
  717. <!-- </tbody> -->
  718. </tbody>
  719. </body>
  720. </html>
  721. <script type="text/javascript">
  722. window.open();
  723. setTimeout(function(){
  724. window.print();
  725. window.close();
  726. }, 250);
  727. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement