$result = $instance_table->SQLExec($A2B->DBHandle, $QUERY, 0); $mail = new Mail(Mail::$TYPE_SUBSCRIPTION_PAID, $card['id']); $mail->replaceInEmail(Mail::$SUBSCRIPTION_FEE, $subscription['fee']); $mail->replaceInEmail(Mail::$SUBSCRIPTION_ID, $subscription['id']); $mail->replaceInEmail(Mail::$SUBSCRIPTION_LABEL, $subscription['product_name']); //update status to paid try { $mail->send(); } catch (A2bMailException $e) { if ($verbose_level >= 1) { echo "[Sent mail failed : {$e}]"; } write_log(LOGFILE_CRONT_SUBSCRIPTIONFEE, basename(__FILE__) . ' line:' . __LINE__ . "[Sent mail failed : {$e}]"); } } else { $reference = generate_invoice_reference(); //CREATE INVOICE If a new card then just an invoice item in the last invoice $field_insert = "date, id_card, title, reference, description, status, paid_status"; $date = date("Y-m-d h:i:s"); $card_id = $card['id']; $title = gettext("SUBSCRIPTION INVOICE REMINDER"); $description = "Your credit was not enough to pay yours subscription automatically.\n"; $description .= "You have {$billdaybefor_anniversary} days to pay this invoice (REF: {$reference} ) or the account will be automatically disactived \n\n"; $value_insert = " '{$date}' , '{$card_id}', '{$title}','{$reference}','{$description}',1,0"; $instance_table = new Table("cc_invoice", $field_insert); if ($verbose_level >= 1) { echo "INSERT INVOICE : {$field_insert} =>\t{$value_insert} \n"; } $id_invoice = $instance_table->Add_table($A2B->DBHandle, $value_insert, null, null, "id"); if (!empty($id_invoice) && is_numeric($id_invoice)) { $description = "Subscription (" . $subscription['product_name'] . ")";
static public function create_invoice_reference() { global $A2B; $FormHandler = FormHandler::GetInstance(); $processed = $FormHandler->getProcessed(); $id_invoice = $FormHandler -> RESULT_QUERY; //CREATE AND UPDATE REF NUMBER $reference = generate_invoice_reference(); $instance_table_invoice = new Table("cc_invoice"); $param_update_invoice = "reference = '".$reference."'"; $clause_update_invoice = " id ='$id_invoice'"; $instance_table_invoice-> Update_table ($FormHandler->DBHandle, $param_update_invoice, $clause_update_invoice, $func_table = null); }