$type = $_POST['types']; $color = $_POST['colors']; $design = $_POST['designs']; $pid = $_POST['pids']; $image = $_POST['images']; $qty = $_POST['qtys']; $retail_price = $_POST['retail_prices']; $cost_price = $_POST['cost_prices']; $total_price = $_POST['subtotals']; $grand_total = 0; //inserting into purchases log foreach ($genres as $index => $genre) { //getting total qty /dozen is default //$total_qty =$qty[$index]*$unit[$index]; $total_qty = convertToEnglishNumber($qty[$index]); $grand_total = $grand_total + convertToEnglishNumber($total_price[$index]); // iterations inserting into purchases if ($index == 0) { mysqli_query($con, "INSERT INTO purchases (factory_name, memo_no, pid, qty, total_qty, retail_price, cost_price, total_price, curr_due, due) \n \t\tVALUES ('{$_POST['factory_name']}','{$_POST['memo_no']}','{$pid[$index]}','{$total_qty}', '{$total_qty}','{$retail_price[$index]}','{$cost_price[$index]}','{$total_price[$index]}','{$_POST['curr_due']}','{$_POST['due']}')"); } else { mysqli_query($con, "INSERT INTO purchases (factory_name, memo_no, pid, qty, total_qty, retail_price, cost_price, total_price, curr_due, due) \n \t\tVALUES ('{$_POST['factory_name']}','{$_POST['memo_no']}','{$pid[$index]}','{$total_qty}', '{$total_qty}','{$retail_price[$index]}','{$cost_price[$index]}','{$total_price[$index]}','{$_POST['curr_due']}','{$_POST['due']}')"); } //updating inventory $result = mysqli_query($con, "SELECT * FROM inventory WHERE pid = '{$pid[$index]}' LIMIT 1"); $row = mysqli_fetch_array($result); if (mysqli_num_rows($result) != 0) { $stock = $row['total_qty']; //echo $stock; //echo " ".$total_qty; $new_stock = $stock + $total_qty; mysqli_query($con, "UPDATE inventory SET total_qty = {$new_stock} WHERE pid = '{$pid[$index]}' ");
$type_result = mysqli_query($con, "SELECT * FROM inventory_config_types WHERE genre = '{$genre_code}' AND serial_no = '{$type_code}' LIMIT 1"); $type_val = mysqli_fetch_array($type_result); $type = $type_val['type']; //echo "type $type<br>"; //echo "Affected rows: " . mysqli_affected_rows($con); $color_result = mysqli_query($con, "SELECT * FROM inventory_config_colors WHERE serial_no = '{$inventory['color']}' LIMIT 1"); $color = mysqli_fetch_array($color_result); $color = $color['color']; $description = "{$genre} {$type}"; // $color"; // if ($description != " "){ // echo $description; // } else{ // echo 'পাওয়া যায়নি'; // } $qty_val = convertToEnglishNumber($qty[$index]); //adding each product for each carton $productMeta["pid"] = $pid; $productMeta["description"] = $description; $productMeta["genre"] = $genre; $productMeta["type"] = $type; $productMeta["price"] = $inventory["retail_price"]; $productMeta["qty"] = $qty_val; $prePackMeta[] = $productMeta; $index++; } //print_r($prePackMeta); //refactoring similar products $packMeta = []; foreach ($prePackMeta as $first => $prod1) { foreach ($prePackMeta as $second => $prod2) {
$row = mysqli_fetch_array($query); echo "{$row['factory_name']}"; echo "</h2>"; ?> </div> </div> <div class="widget-body"> <div class="row-fluid"> <?php if ($_POST) { include "convert_number_encoding.php"; $grand_total = 0; $factory_name = $_POST["factory"]; $grand_total = convertToEnglishNumber($_POST["grand_total"]); $paid = convertToEnglishNumber($_POST["paid"]); //find due $factQry = mysqli_query($con, "SELECT * FROM purchases WHERE factory_name = '{$factory_name}' ORDER BY table_index DESC LIMIT 1"); $found = mysqli_fetch_array($factQry); $due = $found["due"]; $due = $due + $grand_total - $paid; //find memo $memoQry = mysqli_query($con, "SELECT * FROM purchase_memos ORDER BY table_index DESC LIMIT 1"); $foundMemo = mysqli_fetch_array($memoQry); $memo_no = $foundMemo["memo_no"]; $memo_no++; mysqli_query($con, "INSERT INTO purchase_memos (memo_no,factory_name,grand_total,paid,due,purchase_type) VALUES ('{$memo_no}','{$factory_name}','{$grand_total}','{$paid}','{$due}','factory')"); mysqli_query($con, "INSERT INTO purchases (memo_no,factory_name,pid,total_price,due) VALUES ('{$memo_no}','{$factory_name}','shabek',{$grand_total},'{$due}')"); //echo "due is $due"; } ?>
$memo_no = null; if (mysqli_num_rows($memo_result) != 0) { $memo_no = $mal_ferot_last['memo_no'] + 1; } else { $memo_no = 1; } $final_qty = 0; foreach ($_POST['pids'] as $index => $pid) { $design = substr("{$pid}", 8, 3); echo "design {$design}"; $subtotal_price = -1 * $subtotal[$index]; $total_qty = -1 * convertToEnglishNumber($qty[$index]); $final_qty = $final_qty + $total_qty; //echo "'$_POST[company_name]-$_POST[memo_no]-$pid-$total_qty-$retail_price[$index]-$subtotal-$due-$_POST[return]"; // iterations inserting into mal_ferot (sells) mysqli_query($con, "INSERT INTO mal_ferot (company_name, memo_no, pid, total_qty, retail_price, total_price, sell_type)\n\t \t\t VALUES ('{$_POST['company_name']}','{$memo_no}','{$pid}','{$total_qty}','" . convertToEnglishNumber($retail_price[$index]) . "','{$subtotal_price}','return')"); echo "updating mal_ferot Affected rows: " . mysqli_affected_rows($con); //updating inventory $result = mysqli_query($con, "SELECT * FROM inventory WHERE pid = {$pid} LIMIT 1"); $row = mysqli_fetch_array($result); if (mysqli_num_rows($result) != 0) { $stock = $row['total_qty']; //echo $stock; //echo " ".$total_qty; $new_stock = $stock + -1 * $total_qty; //total qty is already negative mysqli_query($con, "UPDATE inventory SET total_qty = {$new_stock} WHERE pid = {$pid}"); } else { /*$pid = substr("$pid", 0,11); echo "pid $pid";*/ $genre = substr("{$pid}", 3, 1);
$result = mysqli_query($con, "SELECT * FROM purchases ORDER BY table_index DESC LIMIT 1"); $row = mysqli_fetch_array($result); $due = $row['due'] - $total_price; $total_price = $total_price * -1; //inserting into purchases log foreach ($_POST['pids'] as $index => $pid) { $cost_price[$index] = $cost_price[$index] * -1; $qty[$index] = convertToEnglishNumber(trim($qty[$index])) * -1; $subtotal = $subtotals[$index] * -1; //fetching factory name $result = mysqli_query($con, "SELECT * FROM inventory WHERE pid = '{$pid}' LIMIT 1"); $row = mysqli_fetch_array($result); $factory = $row['factory_name']; //$retail_price = $row['retail_price']; //getting total qty /dozen is default $total_qty = convertToEnglishNumber(trim($qty[$index])); // iterations inserting into purchases echo 'here'; mysqli_query($con, "INSERT INTO purchases (factory_name, memo_no, pid, total_qty,cost_price, total_price, due) \n \t\tVALUES ('{$factory}','{$memo_no}','{$pid}','{$total_qty}','{$cost_price[$index]}','{$subtotal}','{$due}')"); //updating inventory $result = mysqli_query($con, "SELECT * FROM inventory WHERE pid = '{$pid}' LIMIT 1"); $row = mysqli_fetch_array($result); if (mysqli_num_rows($result) != 0) { $stock = $row['total_qty']; //echo $stock; //echo " ".$total_qty; $new_stock = $stock + $total_qty; mysqli_query($con, "UPDATE inventory SET total_qty = {$new_stock} WHERE pid = {$pid}"); } else { } }
<?php require "conn.php"; include "convert_number_encoding.php"; include "util.php"; $comment = $_POST['comment']; $amount = convertToEnglishNumber($_POST['amount']); $purchase_memos_res = mysqli_query($con, "SELECT * FROM purchase_memos ORDER BY table_index DESC LIMIT 1"); $the = mysqli_fetch_array($purchase_memos_res); $memo_no = $the['memo_no'] + 1; echo "memo_no {$memo_no}"; if ($_POST['purchase_type'] == 'factory') { if (isset($_POST['payCheck'])) { $factoryName = $_POST["name"]; //$amount = $_POST["amount"]+0; $dateString = $_POST["date"]; $dateData = explode('/', $dateString); $dd = @$dateData[0]; $mm = @$dateData[1]; $yy = @$dateData[2]; $date = "{$yy}:{$mm}:{$dd} 01:01:01"; $dateString = $_POST["dateIssued"]; $dateData = explode('/', $dateString); $dd = @$dateData[0]; $mm = @$dateData[1]; $yy = @$dateData[2]; $issue_date = "{$yy}:{$mm}:{$dd} 01:01:01"; //db("insert into company_check () values ()"); //echo "factoryName : $factoryName, date : $date, amount : $amount"; $msg = ""; if ($factoryName == "") {
<?php include "bikri_comm_start.php"; include "util.php"; ?> <!-- <span class="badge"><a href="bikri_shabek_add.php">পার্টি সাবেক</a></span> --> <!-- <span class="badge badge-warning"><a href="mf_shabek_add.php">পার্টি মাল ফেরত সাবেক</a></span> --> <?php include "convert_number_encoding.php"; if ($_POST) { $company_name = @$_POST["company_name"]; $total_qty = @(convertToEnglishNumber($_POST["total_qty"]) * -1) + 0; $grand_total = @(convertToEnglishNumber($_POST["grand_total"]) * -1) + 0; $total_price = $grand_total; $msg = ""; $client = db("select * from clients where company_name='{$company_name}' limit 1"); if ($company_name == "" || $total_qty == 0 || $grand_total == 0) { $msg = "{$msg} সবগুলো ঘর পুরন করুন<br>"; } if ($client == []) { $msg = "{$msg} পার্টিটি তালিকাভুক্ত নয়<br>"; } $last_row = db("select * from sell_memos where company_name = '{$company_name}' order by table_index desc limit 1"); $memo_no = $last_row["memo_no"]; $due = $last_row["due"]; $newDue = $due + $grand_total; //gt is -ve if ($msg == "") { echo "সফল"; // echo "insert into sells (company_name, memo_no,total_qty,total_price, sell_type) values ('$company_name', '$memo_no','$total_qty','$total_price', 'return')";
$type_code = substr($pid, 4, 2); $type_code = (int) $type_code; $type_result = mysqli_query($con, "SELECT * FROM inventory_config_types WHERE genre = '{$genre}' AND serial_no = '{$type_code}' LIMIT 1"); $type_val = mysqli_fetch_array($type_result); $type_name = $type_val['type']; $color_code = substr($pid, 6, 2); $color_code = (int) $color_code; $color_result = mysqli_query($con, "SELECT * FROM inventory_config_colors WHERE serial_no = '{$color_code}' LIMIT 1"); $color_val = mysqli_fetch_array($color_result); $color_name = $color_val['color']; $design_code = substr($pid, 8, 3); $description = "{$genre_name} {$type_name} {$color_name}"; //$type_code : $color_code :length $length"; //echo "<tr>$description</tr>"; //echoing row echo "\n <tr>\n <td>" . $serial . "</td>\n <td>\n {$description}\n <input type=\"hidden\" name=\"genres[]\" value =\"" . $genre . "\">\n <input type=\"hidden\" name=\"types[]\" value =\"" . $type_code . "\">\n <input type=\"hidden\" name=\"colors[]\" value =\"" . $color_code . "\">\n <input type=\"hidden\" name=\"designs[]\" value =\"" . $design_code . "\">\n <input type=\"hidden\" name=\"pids[]\" value =\"" . $pid . "\">\n <input type=\"hidden\" name=\"images[]\" value =\"" . @$paths[$index] . "\"></td>\n <td>\n <label>" . convertToEnglishNumber($qty[$index]) . "</label>\n <input type=\"hidden\" name=\"qtys[]\" value =\"" . convertToEnglishNumber($qty[$index]) . "\"></td>\n <td>\n <label>" . convertToEnglishNumber($retail_price[$index]) . "</label>\n <input type=\"hidden\" name=\"retail_prices[]\" value =\"" . convertToEnglishNumber($retail_price[$index]) . "\"></td>\n <td>\n <label>" . convertToEnglishNumber($cost_price[$index]) . "</label>\n <input type=\"hidden\" name=\"cost_prices[]\" value =\"" . convertToEnglishNumber($cost_price[$index]) . "\"></td>\n <td>\n <label>{$subtotal}</label>\n <input type=\"hidden\" name=\"subtotals[]\" value =\"" . $subtotal . "\"></td>\n </tr>\n "; array_push($prices, "{$subtotal}"); } //calculating total foreach ($prices as $price) { $raw_total = $raw_total + $price; } ?> <!-- post calculations --> <tr> <td></td> <td></td> <td></td> <td></td> <td>মোট</td> <td>
"> <?php $subtotal_1_2 = $grand_total - convertToEnglishNumber($_POST['paid']); echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>মোট :</td>\n <td>" . $subtotal_1_2 . "</td>\n </tr>"; //printing carry cost if (isset($_POST['carry_cost'])) { echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>পাঠানো খরচ :</td>\n <td>" . convertToEnglishNumber($_POST['carry_cost']) . "</td>\n </tr>"; //printing subtotal_2 $subtotal_2 = $subtotal_1_2 + convertToEnglishNumber($_POST['carry_cost']); $grand_total = $subtotal_2; echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>মোট :</td>\n <td>" . $subtotal_2 . "</td>\n </tr>"; echo "<input name=\"carry_cost\" value=\"" . convertToEnglishNumber($_POST['carry_cost']) . "\" type=\"hidden\" >"; } //generate dues & inputs for dues $due = $grand_total + $prev_due; $curr_due = $grand_total - convertToEnglishNumber($_POST['paid']); echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>আগের বাকী :</td>\n <td>" . $prev_due . "</td>\n </tr>"; /* echo "<tr> <td></td> <td></td> <td></td> <td>বাকী :</td> <td>".$curr_due."</td> </tr>";*/ echo "<tr>\n <td>মন্তব্য:</td>\n <td><input type=\"text\" name=\"comment\" value=\"" . $_POST['comment'] . "\" readonly></td>\n <td></td>\n <td>মোট বাকী :</td>\n <td>" . $due . "</td>\n </tr>"; echo "<input name=\"due\" value=\"" . $due . "\" type=\"hidden\" >"; echo "<input name=\"curr_due\" value=\"" . $curr_due . "\" type=\"hidden\" >"; echo "<input name=\"pay_method\" value=\"" . $_POST['pay_method'] . "\" type=\"hidden\" >"; ?> </table> <input class="btn btn-info pull-right" type="submit" value="অনুমোদন" onclick="JavaScript:newPopup('receipt.php?memo_no=<?php
<?php include "bikri_khata_edit_sp_start.php"; include "util.php"; ?> <?php if ($_POST) { $newSp = convertToEnglishNumber($_POST["newSp"]); $memo_no = $_GET["memo_no"]; $sells = db("select * from sells where memo_no = '{$memo_no}' "); if ($sells != []) { db("update sells set total_price = '{$newSp}' where memo_no='{$memo_no}'"); } else { db("insert into sells (memo_no,total_price,sell_type) values ('{$memo_no}','{$newSp}','client')"); } } ?> <form action="edit_sp.php<?php echo "?memo_no={$_GET['memo_no']}"; ?> " method="post"> নতুন দাম: <input type="text" name="newSp" required> <input type="submit" value="যোগ"> </form> <?php include "bikri_khata_end.php";
//generating total amount $raw_total = null; foreach ($prices as $price) { $raw_total = $raw_total + $price; } echo "<tr>\n <td></td>\n <td></td>\n <td>মোট জোড়া</td>\n <td>{$final_qty}</td>\n <td></td>\n </tr>"; echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>মোট দাম :</td>\n <td>" . $raw_total . "</td>\n </tr>"; //commission $commissioned = 1 - convertToEnglishNumber($_POST['commission'] * 0.01); $total_commission = $raw_total * convertToEnglishNumber($_POST['commission']) * 0.01; $total_price = $raw_total * $commissioned; echo "\n <tr>\n <td></td>\n <td></td>\n <td></td>\n <td>মোট কমিশন</td>\n <td>" . $total_commission . "</td>\n </tr>"; echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>কমিশন ছাড়া দাম</td>\n <td>" . $total_price . "</td>\n </tr>"; echo "<input name=\"total_price\" value=\"" . $total_price . "\" type=\"hidden\" >"; echo "<input name=\"raw_total\" value=\"" . $raw_total . "\" type=\"hidden\" >"; echo "<input name=\"commission\" value=\"" . convertToEnglishNumber($_POST['commission']) . "\" type=\"hidden\" >"; //printing previous due $prev_due = null; if (isset($_POST['company_name'])) { $client = $_POST['company_name']; $result = mysqli_query($con, "SELECT * FROM sell_memos WHERE company_name = '{$client}' ORDER BY table_index DESC LIMIT 1"); $row = mysqli_fetch_array($result); $prev_due = $row['due']; } echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>সাবেক বাকি</td>\n <td>" . $prev_due . "</td>\n </tr>"; $total_amount = $total_price + $prev_due; echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>মোট পরিমাণ</td>\n <td>" . $total_amount . "</td>\n </tr>"; echo "<tr>\n <td></td>\n <td></td>\n <td>এক্সট্রা খরচ</td>\n <td><input name=\"extra_cost_descr\" type=\"text\"placeholder=\"মালের বিবরণ\"></td>\n <td><input name=\"extra_cost\" type=\"text\"placeholder=\"টাকার পরিমাণ\"></td>\n </tr>"; echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>পাঠানো খরচ</td>\n <td><input name=\"carry_cost\" type=\"text\"></td>\n </tr>"; echo "<tr>\n <td></td>\n <td></td>\n <td></td>\n <td>জমা</td>\n <td><input name=\"paid\" type=\"text\"></td>\n </tr>"; if (isset($_POST['comment'])) {