Search code examples
phpmysqldatabasecronbilling

Solution to generate invoices on monthly basis automatically?


What is the solution to generate invoices every 2 weeks automatically? Cron Jobs?

I have multiple orders in the tbl_order table, I want to generate an invoices for every 2 weeks (for billing).

    - tbl_order table
    OrderID (PK)
    ShopID (FK)
    CustomerID (FK)
    Status
    Total
    OrderDate

    - invoice table
    InvoiceID (PK)
    InvoiceDate
    InvoiceStatus

   - invoiceorder 
     invoiceorderID (PK)
     InvoiceID (FK)
     OrderID (FK)

The invoice date for Feb would be: 01 - 15 February, 16 - 28 February

and on March: 01 - 15 March, 16 - 31 March

So for example, generate invoice between 01 - 15 March on tbl_order.ShopID = 5

How can that be done if using Cron Jobs / PHP or alternative solution?


Solution

  • To assign cron task, use tutorial like this:

    http://www.thefactory.ro/php-cron-tutorial

    Next, in PHP handler query database for every order that was in that time range and create report based on your needs.