Jump to content

thara

Members
  • Posts

    604
  • Joined

Everything posted by thara

  1. First, Thank you very much sir, for the big help. I tried with your code and its working fine for me. Sir, one thing, here on my printer i am using a sticker paper roll as shown in the image below: Using this code, labels can only be printed on the right side of the paper. As shown in the image below, If I print labels for other two columns, I can do it by adjusting printer setting on my printer. But its not easy for all who use the printer. Sir, can we modify above script to match this paper roll?
  2. Yes that code is working. But just I want to create custom label as attached image with dynamic data. Thats why I try to to create custom code as above. Sir, my I know, what would be the issue on my code?
  3. Using FPDF, I try to create barcode labels as the image attached below. For barcode printing in the label, here I am using Code 128 barcodes script at FPDF. This is how I tried it: //require('./fpdf/barcode-codabar.php'); $data = ['item_name' => 'Fuel Vapour Hose' ,'code_purchase' => 'ABC-2342' ,'code_sale' => 'DFS-4312' ,'item_code' => '47900001' ]; require('./pdf_code128.php'); $pdf=new PDF_Code128(); $barcode = $pdf->Code128( 4,3,$data['item_code'],30,10); class Barcode_Label extends FPDF { protected $data; protected $barcode; //constructor public function __construct(\PDF_Code128 $barcode) { parent::__construct('P','mm',[31,110]); $this->setFillColor(0xDD); $this->barcode = $barcode; } public function printLabel($labelData) { $this->data = $labelData; $this->AddPage(); $this->addLabel(); } private function addLabel() { $k = count($catdata['data']); $this->setFont('Times', 'B', 10); $this->Cell(30, 6, 'Label 1', 'B', 0, 'C'); $this->Cell(30, 6, 'Label 2', 'B', 0, 'C'); $this->Cell(30, 6, 'Label 3', 'B', 0, 'C'); $this->ln(2); } } $label= new Barcode_Label(); $label->printLabel($data); $label->Output(); But this code is not working for me and it gives me
  4. In my DB schema, there are 4 tables and its relationship as shown in the below attached image. My question is how many schools are there according to the data in the school table and how many of those schools belong to provinces, districts and zones, is it possible in one mysql query? Currently I am using 4 separate queries for this and the relevant code is as follows. $sql = "SELECT count(school_id) as schtot FROM sn_school"; $stmt = $pdo->query($sql); $schtot = $stmt->fetchColumn(); $schtot = str_pad($schtot , 3, 0, STR_PAD_LEFT); $sql = "SELECT count(zone_id) as zonetot FROM sn_school GROUP BY zone_id"; $stmt = $pdo->query($sql); $zonetot = $stmt->rowCount(); $zonetot = str_pad($zonetot , 3, 0, STR_PAD_LEFT); $sql = "SELECT COUNT(d.district_id) as districtTot FROM sn_school s JOIN zone z USING(zone_id) JOIN district d ON d.district_id = z.district_id GROUP BY d.district_id"; $stmt = $pdo->query($sql); $districtTot = $stmt->rowCount(); $districtTot = str_pad($districtTot , 3, 0, STR_PAD_LEFT); $sql = "SELECT COUNT(p.province_id) as ptot FROM sn_school s JOIN zone z USING(zone_id) JOIN district d ON d.district_id = z.district_id JOIN district p ON p.province_id = d.province_id GROUP BY p.province_id"; $stmt = $pdo->query($sql); $ptot = $stmt->rowCount(); $ptot = str_pad($ptot , 3, 0, STR_PAD_LEFT);
  5. Side Note: You also can't just insert PHP variables directory into URLs or HTML markup. They have to be escaped and encoded: <?php function html_escape($value, $encoding) { return htmlspecialchars($value, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE, $encoding); } $url = 'icerik.php?'.http_build_query(['icerik' => $goster['icerik_id']]); echo '<a href="'.html_escape($url , 'UTF-8').'">'.html_escape($goster['baslik'], 'UTF-8').'</a>'; ?>
  6. I created a CSV file using Google Sheets. Then it works. I see the problem with the CSV file that I created using Excel on my computer.
  7. Sir, This is how I set charset, when my CSV file is saved.
  8. Sir, can you tell how I specified it on my page? <meta charset="utf-8"> Isn’t this how it was done?
  9. Yes Sir. I have set it inside page <head> tag as shown here. <meta charset="utf-8"> Do I need to set up a charset somewhere else to make it work, sir?
  10. In PHP, I am trying to create an array from a CSV file in this way. // CSV file: $csv = array_map('str_getcsv', file("{$uploadPath}/{$myFile}")); Of course it is working for me, but on thing I have to fixed. If I have non-English language characters in my CSV file, then those characters not showing correctly in PHP. That mean its showing question marks instead of showing original characters. This is the output of $csv array: Array ( [0] => Array ( [0] => SISP-0002 [1] => Harpic Floral 500ml [2] => ???????? ??????? 500ml [3] => 4792037107765 ) ) Can anybody tell me what would be the possible workaround to fix this issue.
  11. Thanks for mentioned it. new array should be in this order. Array ( [13] => 1934.00 [11] => 1716.00 [9] => 1210.00 [7] => 140.00 ) The amout should be clear the balance from oldest baskets
  12. Hi, My expectation is to get an array which is based on a given value. In my POS system, I do have an array that shows all the baskets that still have an outstanding balance to be due by the customer for each basket. The array looks like this: Array ( [15] => 1088.00 [13] => 2206.00 [11] => 1716.00 [9] => 1210.00 [7] => 140.00 ) key = basket_id value = balance due The customer can take the sum of the amount due and make payments in one lump sum or in installments without paying separately for each baskets. My question is, Depending on the amount the customer pays, I need to create a new array. Suppose the amount paid by the customer is 5000, then the new array should be as follows. Array ( [15] => 1088.00 [13] => 2206.00 [11] => 1706.00 ) In this newly created array, array_sum() should be equal to the amount paid by customer. (According to this particular example it should be 5000) Can I know the better workaround for this?
  13. Wow.... Thats the query I needed.. Many many thanks sir.
  14. Sorry for not giving a clear explanation sir. I meant "partial paid" and "partial due", suppose the store made a sale worth 1000, where the customer pays 700 and keeps the remaining 300 as payable to the store. Accordingly partial paid = 700 partial due = 300
  15. Sir, I think that's how it should be. But the relevant calculations should be changed as follows. Total Cash Sales = (cash(paid) + cash(partial paid) + cash on delivery (paid)) Total Credit Sales = (cash(due) + cash(partial due) + Cash on Delivery (due)) Total Cash on Delivery Sales = (cash on Delivery (paid) + Cash on Delivery (due)) Total card sales = (card(paid)
  16. Sir, I really want to get a sales report for the current date. Through this report, I want to get the following data. Total Cash Sales = (cash(paid) + card (paid) + cash on delivery (paid)) Total Credit Sales = (cash(due) + cash(partial) + Cash on Delivery (due)) Total Cash on Delivery Sales = (Cash on Delivery (paid) + Cash on Delivery (due)) Total card sales Sir, is it possible to get those data in a single query?
  17. Ooops! Yes sir It should be OR not AND... This is my updated query and its result as below. Also I changed GROUP BY to payment_method_id. SELECT DATE(bv.sale_time) , CASE WHEN p.payment_method_id IN (1, 2) THEN sum(amount_due) ELSE 0 END AS total_cash_sales , CASE p.payment_method_id WHEN 4 THEN sum(amount_due) ELSE 0 END AS total_credit_sales FROM basket_amount_due bv JOIN basket bt USING(basket_id) LEFT JOIN basket_payment p USING (basket_id) JOIN payment_method m USING(payment_method_id) WHERE DATE(bv.sale_time) = CURDATE() GROUP BY p.payment_method_id; +--------------------+------------------+--------------------+ | DATE(bv.sale_time) | total_cash_sales | total_credit_sales | +--------------------+------------------+--------------------+ | 2021-09-18 | 3042.10 | 0.00 | | 2021-09-18 | 2070.00 | 0.00 | | 2021-09-18 | 0.00 | 1688.40 | +--------------------+------------------+--------------------+ 3 rows in set (0.011 sec)
  18. Thank you Sir. select * from payment_method; +-------------------+-------------------+ | payment_method_id | method | +-------------------+-------------------+ | 1 | CASH | | 2 | Credit/Debit Card | | 3 | Store Credit | | 4 | Cash on Delivery | | 5 | Gift card | | 6 | Credit | +-------------------+-------------------+ 6 rows in set (0.001 sec) select * from basket_payment; +-------------------+-------------------+-----------+-------------+----------------+---------------------+--------------+ | basket_payment_id | payment_method_id | basket_id | amount_paid | amount_balance | date_paid | payment_note | +-------------------+-------------------+-----------+-------------+----------------+---------------------+--------------+ | 1 | 1 | 1 | 1170.00 | 0.00 | 2021-09-18 12:19:04 | | | 2 | 1 | 2 | 0.00 | 0.00 | 2021-09-18 12:19:39 | | | 3 | 1 | 4 | 1000.00 | 0.00 | 2021-09-18 12:20:22 | | | 4 | 4 | 5 | 990.00 | 0.00 | 2021-09-18 12:21:47 | | | 5 | 4 | 7 | 0.00 | 0.00 | 2021-09-18 12:23:33 | | | 8 | 2 | 10 | 2070.00 | 0.00 | 2021-09-18 12:29:45 | | +-------------------+-------------------+-----------+-------------+----------------+---------------------+--------------+ 6 rows in set (0.001 sec)
  19. I have some sales data as below: SELECT bv.sale_time , amount_due , round(sum(amount_paid), 2) as paid , m.payment_method_id , m.method , bt.payment_status FROM basket_amount_due bv JOIN basket bt USING(basket_id) LEFT JOIN basket_payment p USING (basket_id) JOIN payment_method m USING(payment_method_id) GROUP BY bv.basket_id; +---------------------+------------+---------+-------------------+-------------------+----------------+ | sale_time | amount_due | paid | payment_method_id | method | payment_status | +---------------------+------------+---------+-------------------+-------------------+----------------+ | 2021-09-18 12:19:04 | 1170.00 | 1170.00 | 1 | CASH | paid | | 2021-09-18 12:19:39 | 756.60 | 0.00 | 1 | CASH | due | | 2021-09-18 12:20:22 | 1115.50 | 1000.00 | 1 | CASH | partial | | 2021-09-18 12:21:47 | 990.00 | 990.00 | 4 | Cash on Delivery | paid | | 2021-09-18 12:23:33 | 698.40 | 0.00 | 4 | Cash on Delivery | due | | 2021-09-18 12:29:45 | 2070.00 | 2070.00 | 2 | Credit/Debit Card | paid | +---------------------+------------+---------+-------------------+-------------------+----------------+ 6 rows in set (0.004 sec) My question is, Now I need to get total sales by payment method and payment status. That mean I want, total cash sales (= cash(paid) + Card (paid) + Cash on Delivery (paid)) total credit sales (= cash(due) + cash(partial) + Cash on Delivery (due)) total cash on delivery sales (= Cash on Delivery (paid) + Cash on Delivery (due)) total card sales This is the query I have so far.. SELECT DATE(bv.sale_time) , CASE p.payment_method_id WHEN (1 AND 2) THEN sum(amount_due) ELSE 0 END AS total_cash_sales , CASE p.payment_method_id WHEN 4 THEN sum(amount_due) ELSE 0 END AS total_credit_sales FROM basket_amount_due bv JOIN basket bt USING(basket_id) LEFT JOIN basket_payment p USING (basket_id) JOIN payment_method m USING(payment_method_id) WHERE DATE(bv.sale_time) >= CURDATE() AND DATE(bv.sale_time) < CURDATE() + INTERVAL 1 DAY GROUP BY bv.sale_time; Hope somebody may help me out to figure this out.
  20. You can also try CSS "rem" unit for font-size. According to the W3C spec the definition for one rem unit is: This means that 1rem equals the font size of the html element (which for most browsers has a default value of 16px). Eg: .textNewLine { font-size: .735rem; width: 312px; max-width: 312px; font-family: "Lucida Console", "Courier New", monospace; resize: none; overflow: hidden; white-space: break-spaces; } Same result is giving on firefox as well as chrome.
  21. Sir, I do not see any error in the query pointed out by you. Sir, Is it possible to change that single query by setting the permissions to 1 only for the parent and child modules selected by the user?
  22. Sir, I am having a problem with your above single query solution. As you have mentioned, it become permission column to 1, for selected parents and its all child modules. Look at this Example: Query Result: SELECT m.module_id , name , IFNULL(parent, 0) , CASE WHEN p2.module_id IS NULL THEN CASE WHEN p.module_id IS NULL THEN 0 ELSE 1 END ELSE 1 END as permission FROM module m LEFT JOIN user_permission p ON m.module_id = p.module_id AND p.user_id = 38 LEFT JOIN user_permission p2 ON m.parent = p2.module_id AND p2.user_id = 38 ORDER BY m.module_id ; +-----------+------------------+-------------------+------------+ | module_id | name | IFNULL(parent, 0) | permission | +-----------+------------------+-------------------+------------+ | 1 | User Modules | 0 | 0 | | 2 | Items | 1 | 0 | | 3 | Add New Item | 2 | 0 | | 4 | View Item | 2 | 0 | | 5 | Category | 2 | 0 | | 6 | Brand | 2 | 0 | | 7 | Unit | 2 | 0 | | 8 | Purchase | 1 | 1 | | 9 | Add New Purchase | 8 | 1 | | 10 | view Purchase | 8 | 1 | | 11 | Due Invoice | 8 | 1 | | 12 | Return | 8 | 1 | | 13 | Purchase Log | 8 | 1 | | 14 | Inventory | 1 | 0 | | 15 | Stock Transfer | 14 | 0 | | 16 | Stock Adjustment | 14 | 0 | | 17 | Batch Control | 14 | 0 | | 18 | Stock Take | 14 | 0 | +-----------+------------------+-------------------+------------+ Sir, How can we make permision column to 1 only for selected modules?
  23. Sir, I tried it something like this: My parent and child module arrays changed as below: [pmod] => Array ( [2] => 1 [8] => 1 [14] => 1 ) [cmod] => Array ( [8] => Array ( [9] => 1 [10] => 1 [11] => 1 ) [14] => Array ( [15] => 1 [16] => 1 ) ) This is my PHP: // Insert into "user_permission" table: if(!empty($_POST['pmod']) && !empty($_POST['cmod'])) { $modCheked=[]; foreach ($_POST['cmod'] as $pid => $child) { foreach ($child as $cid => $value) { array_push($modCheked, $pid, $cid); $modules = array_unique($modCheked); } } $sql = "INSERT INTO user_permission (module_id,user_id) VALUES (?,?)"; $stmt = $pdo->prepare($sql); foreach ($modules as $k => $mid) { $module_id = intval($mid); $stmt->execute([$module_id, $lastInsertID]); } } From this code, it is inserted all IDs from `cmod` array into DB.
  24. Sir, I have showing a message to user that saying don't select only parent in my front end. But if they select only parent deliberately or by mistake, I need to ignore it from backend. Thats why I am looking for such a solution.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.