Welcome Guest, Not a member yet? Register   Sign In
Text align when creating fwrite()
#1

[eluser]rochellecanale[/eluser]
Hello guys.. actually this is not a CI problem but I am using CI as my framework in building my system. I created a POS system that generates a receipt using a line printer. But when I printed my result all the text are all right align. My problem is how can I align my text? I used fwrite function in PHP and after that i put the result in notepad. Then after that i have a code that calls the last added file (receipt.txt) in the folder named receipt. Here's my sample code I hope you can help me.

Code:
//CREATE TXT FILE FOR RECEIPT PRINTING
        
        $date = date('YmdHis');
        
        $myFile = "c:/receipt/receipt".$date.".txt";
        $fh = fopen($myFile, 'w') or die("can't open file");
        
        $stringData = "Thank you for transacting at ".PHP_EOL."High5 Cellular Tech Solutions".PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = date('M d, Y H:i:s A').PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "Cashier on duty: ".$this->session->userdata('username').PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "".PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "RECEIPT NO. ".$this->input->post('code').PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "".PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "MEMBER'S ID: 00000001".PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "ACCOUNT TYPE: WALK-IN".PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "".PHP_EOL;
        fwrite($fh, $stringData);
        
        $stringData = "****************************************".PHP_EOL;
        fwrite($fh, $stringData);
        
        foreach($products as $p){
            
            $stringData = "SKU ID: ".$p['id'].PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = $p['product_name'].PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "SKU Price: ".$p['product_price'].PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "Quantity: ".$p['product_qty'].PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "Total Purchased: ".number_format($p['product_amount'],2).PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "Payment Method: ".$payment_method.PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "Cash Received: ".number_format($payment,2).PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "Change: ".number_format($change,2).PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "Subtotal: ".number_format($this->session->userdata('subtotal'),2).PHP_EOL;
            fwrite($fh, $stringData);
            
            $stringData = "****************************************".PHP_EOL;
            fwrite($fh, $stringData);

        }
        
        fclose($fh);


Messages In This Thread
Text align when creating fwrite() - by El Forum - 03-20-2013, 08:02 PM
Text align when creating fwrite() - by El Forum - 03-21-2013, 04:43 AM
Text align when creating fwrite() - by El Forum - 03-21-2013, 09:36 AM
Text align when creating fwrite() - by El Forum - 03-21-2013, 04:16 PM
Text align when creating fwrite() - by El Forum - 03-21-2013, 07:32 PM
Text align when creating fwrite() - by El Forum - 03-22-2013, 02:09 AM
Text align when creating fwrite() - by El Forum - 03-22-2013, 05:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB