/**
 * Create the recurrent invoices depeding on the recurrent date.
 * Will get the recurrent invoices for the date where the invoice set as recurrent and will create an invoice with the same data
 * setting the invice due date as today.
 * Will also process the invoice call back object to set the call back url for the online payament for the created invoice
 * @see class/Invoice.class.php
 * @see class/RecurrentInvoice.class.php
 * @see class/InvoiceLine.class.php
 * @see class/InvoiceCallback
 */
include_once "config.php";
set_time_limit(3600);
$do_recurrent = new RecurrentInvoice();
$do_invoice = new Invoice();
$do_inv_line = new InvoiceLine();
$do_recurrent->getRecurrentInvoiceForTheDay();
if ($do_recurrent->getNumRows()) {
    while ($do_recurrent->next()) {
        // Create a new Invoice First
        // if($do_recurrent->idinvoice == '52'  ){ //Testing method by harcoding the idinvoice
        //if($do_recurrent->iduser == 15){
        $do_invoice->addNew();
        $do_invoice->num = $do_invoice->getUniqueInvoiceNum($do_recurrent->iduser);
        $do_invoice->iduser = $do_recurrent->iduser;
        $do_invoice->description = $do_recurrent->description;
        $do_invoice->status = 'Sent';
        $do_invoice->discount = $do_recurrent->discount;
        $do_invoice->invoice_term = $do_recurrent->invoice_term;
        $do_invoice->invoice_address = $do_recurrent->invoice_address;
        $do_invoice->idcompany = $do_recurrent->idcompany;
        $do_invoice->idcontact = $do_recurrent->idcontact;