/** * @EXT\Route( * "/admin/invoice/{invoice}/show", * name="admin_invoice_show" * ) * @EXT\Template */ public function showAction(invoice $invoice) { if ($invoice->getChart()->getOwner() !== $this->tokenStorage->getToken()->getUser() && !$this->authorization->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException(); } return array('invoice' => $invoice); }
/** * Calculates invoice fees and stores it in panel_users, * according to details in billing_service_categories. * * @param int The mode * @param int Userid to begin with Subject, eg tablename. * @param int Number of Users we should handle in this run * @param int Single userid we should focus on. * @return array Results like current invoice fees etc. * * @author Former03 GmbH :: Florian Lippert <*****@*****.**> */ function cacheInvoiceFees($mode = 0, $begin = null, $count = null, $userid = null) { global $db; $returnval = array(); $service_categories_result = $db->query('SELECT * FROM `' . getModeDetails($mode, 'TABLE_BILLING_SERVICE_CATEGORIES', 'table') . '` ORDER BY `id` ASC'); while ($service_categories_row = $db->fetch_array($service_categories_result)) { $service_categories[$service_categories_row['category_name']] = $service_categories_row; if ($service_categories_row['category_cachefield'] != '') { $zeroUpdates[$service_categories_row['category_cachefield']] = 0; } } if ($userid !== null && intval($userid) !== 0) { $userSelection = " WHERE `" . getModeDetails($mode, 'TABLE_PANEL_USERS', 'key') . "` = '" . $userid . "' "; } else { $userSelection = ''; } if ($begin !== null && intval($count) !== 0) { $limit = ' LIMIT ' . intval($begin) . ', ' . intval($count); } else { $limit = ''; } $users = $db->query("SELECT * FROM `" . getModeDetails($mode, 'TABLE_PANEL_USERS', 'table') . "` " . $userSelection . ' ' . $limit); while ($user = $db->fetch_array($users)) { if (!isset($user['customer_categories_once'])) { $user['customer_categories_once'] = ''; } if (!isset($user['customer_categories_period'])) { $user['customer_categories_period'] = ''; } $myInvoice = new invoice($db, $mode, explode('-', $user['customer_categories_once']), explode('-', $user['customer_categories_period'])); if ($myInvoice->collect($user[getModeDetails($mode, 'TABLE_PANEL_USERS', 'key')]) === true) { $total_fee_taxed = 0; $myUpdates = $zeroUpdates; $total_fees_array = $myInvoice->getTotalFee($lng); foreach ($total_fees_array as $service_type => $total_fee_array) { if (isset($service_categories[$service_type]) && isset($service_categories[$service_type]['category_cachefield']) && $service_categories[$service_type]['category_cachefield'] != '') { $myUpdates[$service_categories[$service_type]['category_cachefield']] = $total_fee_array['total_fee_taxed']; $total_fee_taxed += $total_fee_array['total_fee_taxed']; } } $updates = ''; foreach ($myUpdates as $myField => $myValue) { $updates .= ', `' . $myField . '` = \'' . $myValue . '\' '; } $db->query('UPDATE `' . getModeDetails($mode, 'TABLE_PANEL_USERS', 'table') . '` SET `invoice_fee` = \'' . $total_fee_taxed . '\' ' . $updates . ' WHERE `' . getModeDetails($mode, 'TABLE_PANEL_USERS', 'key') . '` = \'' . $user[getModeDetails($mode, 'TABLE_PANEL_USERS', 'key')] . '\' '); $returnval[$user[getModeDetails($mode, 'TABLE_PANEL_USERS', 'key')]] = $myUpdates; $returnval[$user[getModeDetails($mode, 'TABLE_PANEL_USERS', 'key')]]['total'] = $total_fee_taxed; $returnval[$user[getModeDetails($mode, 'TABLE_PANEL_USERS', 'key')]]['loginname'] = $user['loginname']; } } return $returnval; }
/** * Add Invoice */ public function addInvoice($customer_id) { // Validation Rules $validator = Validator::make(['customer_id' => $customer_id], ['customer_id' => 'integer']); // If Validation Fails if ($validator->fails()) { return redirect('/customers')->withErrors($validator->messages()->toArray()); } // Start a new invoice model $invoice = new invoice(); // Edit Properties $invoice->customer_id = $customer_id; $invoice_id = $invoice->save(); // Redirect to the invoice profile return redirect('/invoice/' . $invoice_id); }
function submit_paypal_post() { global $dbh, $postvar, $getvar, $instance; echo "<form action=" . $this->paypal_url . " method='post' name='frm'>"; foreach ($this->fields as $a => $b) { if ($a == "amount") { if ($b == "0") { $user_data = $dbh->select("users", array("id", "=", $_SESSION['cuser'])); $signup_date = date("m-d-Y", $user_data['signup']); if ($signup_date == date("m-d-Y")) { $noemail = "1"; } invoice::set_paid($getvar['iid'], $noemail); main::redirect("../client/?page=invoices"); exit; } } echo "<input type='hidden' name='" . $a . "' value='" . $b . "'>"; } echo '</form> <script language="JavaScript"> document.frm.submit(); </script>'; exit; }
function save() { if (!imp($this->get_value("iiAmount"))) { $this->set_value("iiAmount", $this->get_value("iiQuantity") * $this->get_value("iiUnitPrice")); } $status = parent::save(); $status2 = invoice::update_invoice_dates($this->get_value("invoiceID")); return $status && $status2; }
function save_invoice_timeSheet($invoiceID, $timeSheetID) { global $TPL; $invoice = new invoice($invoiceID); if ($invoice->get_value("invoiceStatus") != "finished") { $timeSheet = new timeSheet(); $timeSheet->set_id($timeSheetID); $timeSheet->select(); $timeSheet->load_pay_info(); $project = $timeSheet->get_foreign_object("project"); $date = $timeSheet->get_value("dateFrom") or $date = date("Y-m-d"); // customerBilledDollars will not be set if the actual field is blank, // and thus there won't be a usable total_customerBilledDollars. if (isset($timeSheet->pay_info["customerBilledDollars"])) { $amount = $timeSheet->pay_info["total_customerBilledDollars"]; $iiUnitPrice = $timeSheet->pay_info["customerBilledDollars"]; $iiQuantity = $timeSheet->pay_info["total_duration"]; } else { $amount = $timeSheet->pay_info["total_dollars"]; $iiUnitPrice = $amount; $iiQuantity = 1; } $q = prepare("SELECT * FROM invoiceItem WHERE invoiceID = %d AND timeSheetID = %d AND timeSheetItemID IS NULL\n ", $invoiceID, $timeSheetID); $db = new db_alloc(); $db->query($q); $row = $db->row(); $ii = new invoiceItem(); if ($row) { $ii->set_id($row["invoiceItemID"]); } $ii->set_value("invoiceID", $invoiceID); $ii->set_value("timeSheetID", $timeSheet->get_id()); $ii->set_value("iiMemo", "Time Sheet #" . $timeSheet->get_id() . " for " . person::get_fullname($timeSheet->get_value("personID")) . ", Project: " . $project->get_value("projectName")); $ii->set_value("iiQuantity", $iiQuantity); $ii->set_value("iiUnitPrice", $iiUnitPrice); $ii->set_value("iiAmount", $amount); $ii->set_value("iiDate", $date); $ii->set_value("iiTax", config::get_config_item("taxPercent")); $ii->currency = $timeSheet->get_value("currencyTypeID"); $ii->save(); } else { alloc_error("Unable to update related Invoice (ID:" . $invoiceID . ")."); } }
public function detail() { //get expenseaccount $expenseaccountobj = new expenseaccount(); $detail['expense_account_all'] = $expenseaccountobj->get_all(); //get customers with domain_id from session by constructor $customerobj = new customer(); $detail['customer'] = $customerobj->get(); $detail['customer_all'] = $customerobj->get_all(); //get billers with domain_id from session by constructor $billerobj = new biller(); $detail['biller_all'] = $billerobj->get_all(); //get invoices $invoiceobj = new invoice(); $detail['invoice_all'] = $invoiceobj->get_all(); //get products $productobj = new product(); $detail['product_all'] = $productobj->get_all(); return $detail; }
public function newItem($id, $requestData) { $invoice = invoice::findOrFail($id); $tasktimeId = $invoice->tasktime()->first()->fk_task_id; $clientid = $invoice->clients()->first()->id; $input = array_replace($requestData->all(), ['fk_task_id' => "{$tasktimeId}"]); $tasktime = TaskTime::create($input); $insertedId = $tasktime->id; $invoice->tasktime()->attach($insertedId); $invoice->clients()->attach($clientid); }
function show_filter() { global $TPL; global $defaults; $_FORM = invoice::load_form_data($defaults); $arr = invoice::load_invoice_filter($_FORM); is_array($arr) and $TPL = array_merge($TPL, $arr); $payment_statii = invoice::get_invoice_statii_payment(); foreach ($payment_statii as $payment_status => $label) { $summary .= "\n" . $nbsp . invoice::get_invoice_statii_payment_image($payment_status) . " " . $label; $nbsp = " "; } $TPL["status_legend"] = $summary; include_template("templates/invoiceListFilterS.tpl"); }
public static function detail() { //get customers $detail['expense_account_all'] = expenseaccount::get_all(); //get customers $detail['customer'] = customer::get(); $detail['customer_all'] = customer::get_all(); //get billers $detail['biller_all'] = biller::get_all(); //get invoices $detail['invoice_all'] = invoice::get_all(); //get products $detail['product_all'] = product::get_all(); return $detail; }
function get_all_parties($invoiceID) { if ($invoiceID) { $invoice = new invoice(); $invoice->set_id($invoiceID); $invoice->select(); $interestedPartyOptions = $invoice->get_all_partieS($invoice->get_value("projectID"), $invoice->get_value("clientID")); } if (is_object($this) && $this->get_id()) { $interestedPartyOptions = interestedParty::get_interested_parties("invoiceRepeat", $this->get_id(), $interestedPartyOptions); } return $interestedPartyOptions; }
function show_invoices() { $current_user =& singleton("current_user"); global $project; $clientID = $project->get_value("clientID"); $projectID = $project->get_id(); $_FORM["showHeader"] = true; $_FORM["showInvoiceNumber"] = true; $_FORM["showInvoiceClient"] = true; $_FORM["showInvoiceName"] = true; $_FORM["showInvoiceAmount"] = true; $_FORM["showInvoiceAmountPaid"] = true; $_FORM["showInvoiceDate"] = true; $_FORM["showInvoiceStatus"] = true; $_FORM["clientID"] = $clientID; $_FORM["projectID"] = $projectID; // Restrict non-admin users records if (!$current_user->have_role("admin")) { $_FORM["personID"] = $current_user->get_id(); } $rows = invoice::get_list($_FORM); echo invoice::get_list_html($rows, $_FORM); }
*/ define("BROWSE","browse"); //if this page has error with auth remove the above line and figure out how to do it right $SI_INVOICE_TYPE = new SimpleInvoices_Db_Table_InvoiceType(); $domain_id = domain_id::get(); #$sql = "SELECT * FROM ".TB_PREFIX."invoices where domain_id = ".$domain_id; #global $dbh; #$sth = dbQuery($sql) or die(htmlsafe(end($dbh->errorInfo()))); //$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit"; $invoice = new invoice(); $sth = $invoice->select_all(); $q = strtolower($_GET["q"]); if (!$q) return; while ($invoice = getInvoices($sth)) { $invoiceType = $SI_INVOICE_TYPE->getInvoiceType($invoice['type_id']); if (strpos(strtolower($invoice['index_id']), $q) !== false) { $invoice['id'] = htmlsafe($invoice['id']); $invoice['total'] = htmlsafe(number_format($invoice['total'],2)); $invoice['paid'] = htmlsafe(number_format($invoice['paid'],2)); $invoice['owing'] = htmlsafe(number_format($invoice['owing'],2)); echo "$invoice[id]|<table><tr><td class='details_screen'>$invoice[preference]:</td><td>$invoice[index_id]</td><td class='details_screen'>Total: </td><td>$invoice[total] </td></tr><tr><td class='details_screen'>Biller: </td><td>$invoice[biller] </td><td class='details_screen'>Paid: </td><td>$invoice[paid] </td></tr><tr><td class='details_screen'>Customer: </td><td>$invoice[customer] </td><td class='details_screen'>Owing: </td><td><u>$invoice[owing]</u></td></tr></table>\n";
<?php header("Content-type: text/xml"); //$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ; $dir = isset($_POST['sortorder']) ? $_POST['sortorder'] : "DESC"; $sort = isset($_POST['sortname']) ? $_POST['sortname'] : "id"; $rp = isset($_POST['rp']) ? $_POST['rp'] : "25"; $having = isset($_GET['having']) ? $_GET['having'] : ""; $page = isset($_POST['page']) ? $_POST['page'] : "1"; //$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit"; $invoice = new invoice(); $invoice->sort = $sort; if ($auth_session->role_name == 'customer') { $invoice->customer = $auth_session->user_id; } elseif ($auth_session->role_name == 'biller') { $invoice->biller = $auth_session->user_id; } $invoice->query = isset($_REQUEST['query']) ? $_REQUEST['query'] : null; $invoice->qtype = isset($_REQUEST['qtype']) ? $_REQUEST['qtype'] : null; $large_dataset = getDefaultLargeDataset(); if ($large_dataset == $LANG['enabled']) { $sth = $invoice->select_all('large', $dir, $rp, $page, $having); $sth_count_rows = $invoice->count(); $invoice_count = $sth_count_rows->fetch(PDO::FETCH_ASSOC); $invoice_count = $invoice_count['count']; } else { $sth = $invoice->select_all('', $dir, $rp, $page, $having); $sth_count_rows = $invoice->select_all('count', $dir, $rp, $page, $having); $invoice_count = $sth_count_rows->rowCount(); } $invoices = $sth->fetchAll(PDO::FETCH_ASSOC);
<?php header("Content-type: text/xml"); //$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ; $dir = (isset($_POST['sortorder'])) ? $_POST['sortorder'] : "DESC" ; $sort = (isset($_POST['sortname'])) ? $_POST['sortname'] : "id" ; $rp = (isset($_POST['rp'])) ? $_POST['rp'] : "25" ; $having = (isset($_GET['having'])) ? $_GET['having'] : "" ; $page = (isset($_POST['page'])) ? $_POST['page'] : "1" ; $baseUrl = Zend_Registry::get('baseUrl'); //$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit"; $invoice = new invoice(); $invoice->sort=$sort; $invoice->query=$_REQUEST['query']; $invoice->qtype=$_REQUEST['qtype']; $invoice->sort=$sort; // if role is customer then select only on customer!!! if ($auth_session -> role_name == "customer") { // find 'id' from customer table, based upon the email $id = $invoice->select_customer_id($auth_session->email); $invoice->customer = $id; } $sth = $invoice->select_all('', $dir, $rp, $page, $having); $sth_count_rows = $invoice->select_all('count',$dir, $rp, $page, $having); $invoices = $sth->fetchAll(PDO::FETCH_ASSOC);
function invoice_form_delete_process($type, $returnpage_error, $returnpage_success) { log_debug("inc_invoices_forms", "Executing invoice_form_delete_process({$type}, {$mode}, {$returnpage_error}, {$returnpage_success})"); $invoice = new invoice(); $invoice->type = $type; /* Import POST Data */ $invoice->id = @security_form_input_predefined("int", "id_invoice", 1, ""); $data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion"); // we don't use this value (since we can't trust it) but we need to read it // in here to work around a limitation in the Amberphplib framework $data["code_invoice"] = @security_form_input_predefined("any", "code_invoice", 1, ""); /* Error Handling */ // make sure the invoice actually exists if (!$invoice->verify_invoice()) { log_write("error", "process", "The invoice you have attempted to delete - " . $invoice->id . " - does not exist in this system."); } // check if invoice is locked or not if ($invoice->check_delete_lock()) { log_write("error", "process", "The invoice can not be deleted because it is locked."); } // return to input page in event of an error if ($_SESSION["error"]["message"]) { $_SESSION["error"]["form"][$type . "_invoice_delete"] = "failed"; header("Location: ../../index.php?page={$returnpage_error}&id=" . $invoice->id); exit(0); } /* Delete Invoice */ if ($invoice->action_delete()) { $_SESSION["notification"]["message"] = array("Invoice has been successfully deleted."); } else { $_SESSION["error"]["message"][] = "Some problems were experienced while deleting the invoice."; } // display updated details header("Location: ../../index.php?page={$returnpage_success}&id={$id}"); exit(0); }
$patch['208']['patch'] = "ALTER TABLE `" . TB_PREFIX . "preferences` ADD `index_group` INT( 11 ) NOT NULL ;"; $patch['208']['date'] = "20090826"; $defaults = getSystemDefaults(); $patch['209']['name'] = "Populate the status, locale, and language fields in preferences table"; $patch['209']['patch'] = "UPDATE `" . TB_PREFIX . "preferences` SET index_group = '" . $defaults['preference'] . "' ;"; $patch['209']['date'] = "20090826"; $patch['210']['name'] = "Create composite primary key for invoice table"; $patch['210']['patch'] = "ALTER TABLE `" . TB_PREFIX . "invoices` DROP PRIMARY KEY, ADD PRIMARY KEY(`domain_id`,`id` );"; $patch['210']['date'] = "20090826"; $patch['211']['name'] = "Reset auto-increment for invoice table"; $patch['211']['patch'] = "ALTER TABLE `" . TB_PREFIX . "invoices` AUTO_INCREMENT = 1;"; $patch['211']['date'] = "20090826"; $patch['212']['name'] = "Copy invoice.id into invoice.index_id"; $patch['212']['patch'] = "update `" . TB_PREFIX . "invoices` set index_id = id;"; $patch['212']['date'] = "20090902"; $invoiceobj = new invoice(); $max_invoice = $invoiceobj->max(); unset($invoiceobj); $patch['213']['name'] = "Update the index table with max invoice id - if required"; if ($max_invoice > "0") { $patch['213']['patch'] = "insert into `" . TB_PREFIX . "index` (id, node, sub_node, domain_id) VALUES (" . $max_invoice . ", 'invoice', '" . $defaults['preference'] . "','1');"; } else { $patch['213']['patch'] = "select 1+1;"; } $patch['213']['date'] = "20090902"; unset($defaults); unset($max_invoice); $patch['214']['name'] = "Add sub_node_2 to si_index table"; $patch['214']['patch'] = "ALTER TABLE `" . TB_PREFIX . "index` ADD `sub_node_2` VARCHAR( 255 ) NULL AFTER `sub_node`"; $patch['214']['date'] = "20090912"; $patch['215']['name'] = "si_invoices - add composite primary key - patch removed";
/** * User initiate domain renewal */ function user_renew_domain($VAR) { # Validate user is owner of this domain $db =& DB(); $rs = $db->Execute(sqlSelect($db, 'service', '*', "id = ::{$VAR['id']}:: AND account_id = " . SESS_ACCOUNT)); if (!SESS_LOGGED or !$rs or $rs->RecordCount() == 0) { global $C_debug; $C_debug->alert('Unable to renew domain at this time'); return; } include_once PATH_MODULES . 'invoice/invoice.inc.php'; $invoice = new invoice(); $id = $invoice->generatedomaininvoice($rs->fields, $invoice); if ($id) { global $VAR; $VAR['id'] = $id; define('FORCE_PAGE', "invoice:user_view"); } }
#amount paid calc - start $stuff['paid'] = calc_customer_paid($customer['id'], domain_id::get(), true); #amount paid calc - end #amount owing calc - start $stuff['owing'] = $stuff['total'] - $stuff['paid']; #get custom field labels $customFieldLabel = getCustomFieldLabels(); $invoices = getCustomerInvoices($customer_id); //$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ; $dir = "DESC"; $sort = "id"; $rp = isset($_POST['rp']) ? $_POST['rp'] : "25"; $having = 'money_owed'; $page = isset($_POST['page']) ? $_POST['page'] : "1"; //$sql = "SELECT * FROM ".TB_PREFIX."invoices LIMIT $start, $limit"; $invoice_owing = new invoice(); $invoice_owing->sort = $sort; $invoice_owing->having_and = "real"; $invoice_owing->query = $_REQUEST['query']; $invoice_owing->qtype = $_REQUEST['qtype']; $large_dataset = getDefaultLargeDataset(); if ($large_dataset == $LANG['enabled']) { $sth = $invoice_owing->select_all('large_count', $dir, $rp, $page, $having); } else { $sth = $invoice_owing->select_all('', $dir, $rp, $page, $having); } $invoices_owing = $sth->fetchAll(PDO::FETCH_ASSOC); //$customFieldLabel = getCustomFieldLabels("biller"); $smarty->assign("stuff", $stuff); $smarty->assign('customer', $customer); $smarty->assign('invoices', $invoices);
* GPL v2 or above * * Website: * http://www.simpleinvoices.or */ checkLogin(); #get the invoice id $invoice_id = $_GET['id']; $invoice = getInvoice($invoice_id); $invoice_number_of_taxes = numberOfTaxesForInvoice($invoice_id); $invoice_type = getInvoiceType($invoice['type_id']); $customer = getCustomer($invoice['customer_id']); $biller = getBiller($invoice['biller_id']); $preference = getPreference($invoice['preference_id']); $defaults = getSystemDefaults(); $invoiceobj = new invoice(); $invoiceItems = $invoiceobj->getInvoiceItems($invoice_id); $eway_check = new eway(); $eway_check->invoice = $invoice; $eway_pre_check = $eway_check->pre_check(); #Invoice Age - number of days - start if ($invoice['owing'] > 0) { $invoice_age_days = number_format((strtotime(date('Y-m-d')) - strtotime($invoice['calc_date'])) / (60 * 60 * 24), 0); $invoice_age = "{$invoice_age_days} {$LANG['days']}"; } else { $invoice_age = ""; } $url_for_pdf = "./index.php?module=export&view=pdf&id=" . $invoice['id']; $invoice['url_for_pdf'] = $url_for_pdf; $customFieldLabels = getCustomFieldLabels(); for ($i = 1; $i <= 4; $i++) {
**/ include './lib/customer.defines.php'; include './lib/customer.module.access.php'; include './lib/customer.smarty.php'; include './lib/support/classes/invoice.php'; include './lib/support/classes/invoiceItem.php'; if (!has_rights(ACX_INVOICES)) { Header("HTTP/1.0 401 Unauthorized"); Header("Location: PP_error.php?c=accessdenied"); die; } getpost_ifset(array('id')); if (empty($id)) { Header("Location: A2B_entity_invoice.php?atmenu=payment§ion=13"); } $invoice = new invoice($id); if ($invoice->getCard() != $_SESSION["card_id"]) { Header("HTTP/1.0 401 Unauthorized"); Header("Location: PP_error.php?c=accessdenied"); die; } $items = $invoice->loadItems(); //load customer $DBHandle = DbConnect(); $card_table = new Table('cc_card', '*'); $card_clause = "id = " . $_SESSION["card_id"]; $card_result = $card_table->Get_list($DBHandle, $card_clause, 0); $card = $card_result[0]; if (empty($card)) { echo "Customer doesn't exist or is not correctly defined for this invoice !"; die;
$saved = "false"; $inventory = new inventory(); $inventory->id=$_GET['id']; $inventory->domain_id=domain_id::get(); $inventory->product_id=$_POST['product_id']; $inventory->quantity=$_POST['quantity']; $inventory->cost=$_POST['cost']; $inventory->date=$_POST['date']; $inventory->note=$_POST['note']; $result = $inventory->update(); $saved = !empty($result) ? "true" : "false"; } $invoices = new invoice(); $invoices->sort='id'; $invoice_all = $invoices->select_all('count'); $get_inventory = new inventory(); $get_inventory->id = $_GET['id']; $inventory = $get_inventory->select(); $product_all = product::get_all(); $smarty -> assign('product_all',$product_all); $smarty -> assign('saved',$saved); $smarty -> assign('inventory',$inventory); $smarty -> assign('pageActive', 'inventory'); $smarty -> assign('subPageActive', 'inventory_edit'); $smarty -> assign('active_tab', '#product');
function execute() { log_debug("invoice_form_export", "Executing execute()"); /* Fetch basic invoice details */ $obj_sql_invoice = new sql_query(); if ($this->type == "ar") { $obj_sql_invoice->string = "SELECT code_invoice, customerid FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "' LIMIT 1"; } else { $obj_sql_invoice->string = "SELECT code_quote, customerid FROM account_" . $this->type . " WHERE id='" . $this->invoiceid . "' LIMIT 1"; } $obj_sql_invoice->execute(); $obj_sql_invoice->fetch_array(); /* Generate Email This function call provides us with all the email fields we can use to complete the form with. */ $obj_invoice = new invoice(); $obj_invoice->type = $this->type; $obj_invoice->id = $this->invoiceid; $email = $obj_invoice->generate_email(); /* Define email form */ $this->obj_form_email = new form_input(); $this->obj_form_email->formname = "invoice_export_email"; $this->obj_form_email->language = $_SESSION["user"]["lang"]; $this->obj_form_email->action = $this->processpage; $this->obj_form_email->method = "post"; // general $structure = NULL; $structure["fieldname"] = "sender"; $structure["type"] = "radio"; $structure["defaultvalue"] = $email["sender"]; $structure["values"] = array("system", "user"); $structure["translations"]["system"] = sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_NAME'") . " <" . sql_get_singlevalue("SELECT value FROM config WHERE name='COMPANY_CONTACT_EMAIL'") . ">"; $structure["translations"]["user"] = user_information("realname") . " <" . user_information("contact_email") . ">"; $this->obj_form_email->add_input($structure); $structure = NULL; $structure["fieldname"] = "subject"; $structure["type"] = "input"; $structure["defaultvalue"] = $email["subject"]; $structure["options"]["width"] = "600"; $this->obj_form_email->add_input($structure); $structure = NULL; $structure["fieldname"] = "email_to"; $structure["type"] = "input"; $structure["defaultvalue"] = $email["to"]; $structure["options"]["width"] = "600"; $this->obj_form_email->add_input($structure); $structure = NULL; $structure["fieldname"] = "email_cc"; $structure["type"] = "input"; $structure["defaultvalue"] = $email["cc"]; $structure["options"]["width"] = "600"; $this->obj_form_email->add_input($structure); $structure = NULL; $structure["fieldname"] = "email_bcc"; $structure["type"] = "input"; $structure["defaultvalue"] = $email["bcc"]; $structure["options"]["width"] = "600"; $this->obj_form_email->add_input($structure); $structure = NULL; $structure["fieldname"] = "email_message"; $structure["type"] = "textarea"; $structure["defaultvalue"] = $email["message"]; $structure["options"]["width"] = "600"; $structure["options"]["height"] = "100"; $this->obj_form_email->add_input($structure); // hidden $structure = NULL; $structure["fieldname"] = "formname"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->obj_form_email->formname; $this->obj_form_email->add_input($structure); $structure = NULL; $structure["fieldname"] = "id_invoice"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->invoiceid; $this->obj_form_email->add_input($structure); // submit button $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Send via Email"; $this->obj_form_email->add_input($structure); // load any data returned due to errors $this->obj_form_email->load_data_error(); /* Define download form */ $this->obj_form_download = new form_input(); $this->obj_form_download->formname = "invoice_export_download"; $this->obj_form_download->language = $_SESSION["user"]["lang"]; $this->obj_form_download->action = $this->processpage; $this->obj_form_download->method = "post"; // general $structure = NULL; $structure["fieldname"] = "invoice_mark_as_sent"; $structure["type"] = "checkbox"; $structure["options"]["label"] = "Check this to show that the invoice has been sent to the customer when you download the PDF"; $this->obj_form_download->add_input($structure); // hidden $structure = NULL; $structure["fieldname"] = "formname"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->obj_form_download->formname; $this->obj_form_download->add_input($structure); $structure = NULL; $structure["fieldname"] = "id_invoice"; $structure["type"] = "hidden"; $structure["defaultvalue"] = $this->invoiceid; $this->obj_form_download->add_input($structure); // submit button $structure = NULL; $structure["fieldname"] = "submit"; $structure["type"] = "submit"; $structure["defaultvalue"] = "Download as PDF"; $this->obj_form_download->add_input($structure); // load any data returned due to errors $this->obj_form_download->load_data_error(); return 1; }
**/ include '../lib/admin.defines.php'; include '../lib/admin.module.access.php'; include '../lib/admin.smarty.php'; include '../lib/support/classes/invoice.php'; include '../lib/support/classes/invoiceItem.php'; if (!has_rights(ACX_INVOICING)) { Header("HTTP/1.0 401 Unauthorized"); Header("Location: PP_error.php?c=accessdenied"); die; } getpost_ifset(array('id', 'addpayment', 'delpayment', 'status')); if (empty($id)) { Header("Location: A2B_entity_invoice.php?atmenu=payment§ion=13"); } $invoice = new invoice($id); $items = $invoice->loadItems(); if (isset($addpayment) && is_numeric($addpayment)) { $invoice->addPayment($addpayment); Header("Location: A2B_invoice_manage_payment.php?id={$id}"); } if (isset($delpayment) && is_numeric($delpayment)) { $invoice->delPayment($delpayment); Header("Location: A2B_invoice_manage_payment.php?id={$id}"); } if (isset($status) && is_numeric($status)) { $invoice->changeStatus($status); Header("Location: A2B_invoice_manage_payment.php?id={$id}"); } $smarty->display('main.tpl'); $payments = $invoice->loadPayments();
$obj_sql_invoice->string = "SELECT code_invoice, customerid FROM account_ar WHERE id='" . $invoice_id . "' LIMIT 1"; $obj_sql_invoice->execute(); $obj_sql_invoice->fetch_array(); //fetch basic customer details $obj_sql_contact = new sql_query(); $obj_sql_contact->string = "SELECT id, contact FROM customer_contacts WHERE customer_id = '" . $obj_sql_invoice->data[0]["customerid"] . "' AND role = 'accounts'"; $obj_sql_contact->execute(); $obj_sql_contact->fetch_array(); //fetch email to address, set error if no address is set $to = sql_get_singlevalue("SELECT detail AS value FROM customer_contact_records WHERE contact_id = '" . $obj_sql_contact->data[0]["id"] . "' AND type = 'email' LIMIT 1"); if (!$to) { $error_array[] = $obj_sql_invoice->data[0]["code_invoice"]; continue; } //create invoice $obj_invoice = new invoice(); $obj_invoice->type = "ar"; $obj_invoice->id = $invoice_id; $obj_invoice->load_data(); $obj_invoice->load_data_export(); //get templating keys and values $invoice_data = $obj_invoice->invoice_fields; $invoice_data_parts['keys'] = array_keys($invoice_data); $invoice_data_parts['values'] = array_values($invoice_data); foreach ($invoice_data_parts['keys'] as $index => $key) { $invoice_data_parts['keys'][$index] = "(" . $key . ")"; } foreach ($invoice_data_parts['values'] as $index => $value) { $invoice_data_parts['values'][$index] = trim($value); } $invoice_data_parts['keys'][] = "(days_overdue)";
} if ($number_of_payments == '0') { $payment = new payment(); $payment->ac_inv_id = $_POST['pg_consumerorderid']; $payment->ac_amount = $_POST['pg_total_amount']; $payment->ac_notes = $paypal_data; $payment->ac_date = date('Y-m-d'); $payment->online_payment_id = $_POST['pg_consumerorderid']; $payment->domain_id = '1'; $payment_type = new payment_type(); $payment_type->type = "ACH"; $payment_type->domain_id = '1'; $payment->ac_payment_type = $payment_type->select_or_insert_where(); $logger->log('ACH - payment_type=' . $payment->ac_payment_type, Zend_Log::INFO); $payment->insert(); $invoiceobj = new invoice(); $invoice = $invoiceobj->select($_POST['pg_consumerorderid']); $biller = getBiller($invoice['biller_id']); //send email $body = "A PaymentsGateway.com payment of " . $_POST['pg_total_amount'] . " was successfully received into Simple Invoices\n"; $body .= "for invoice: " . $_POST['pg_consumerorderid']; $body .= " from " . $_POST['pg_billto_postal_name_company'] . " on " . date('m/d/Y'); $body .= " at " . date('g:i A') . "\n\nDetails:\n"; $body .= $paypal_data; $email = new email(); $email->notes = $body; $email->to = $biller['email']; $email->from = "*****@*****.**"; $email->subject = 'PaymentsGateway.com -Instant Payment Notification - Recieved Payment'; $email->send(); $xml_message = "+++++++++<br /><br />";
/* * Script: email.php * Email invoice page * * License: * GPL v3 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $invoice_id = $_GET['id']; $invoiceobj = new invoice(); $invoice = $invoiceobj->select($invoice_id); $preference = getPreference($invoice['preference_id']); $biller = getBiller($invoice['biller_id']); $customer = getCustomer($invoice['customer_id']); $invoiceType = getInvoiceType($invoice['type_id']); #create PDF name $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name = $spc2us_pref . '.pdf'; if ($_GET['stage'] == 2) { #echo $block_stage2; // Create invoice $export = new export(); $export->format = "pdf"; $export->file_location = 'file'; $export->module = 'invoice';
function delete($VAR) { $db =& DB(); global $C_auth, $C_list; # set the id $id = $this->table . '_id'; # generate the list of ID's $id_list = ''; $account_id_list = ''; $discount_id_list = ''; $ii = 0; if (isset($VAR["delete_id"])) { $id = explode(',', $VAR["delete_id"]); } elseif (isset($VAR["id"])) { $id = explode(',', $VAR["id"]); } for ($i = 0; $i < count($id); $i++) { if ($id[$i] != '') { ### is current account auth to delete this account? ### Get any authorized groups: $db =& DB(); $sql = 'SELECT group_id FROM ' . AGILE_DB_PREFIX . 'account_group WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND account_id = ' . $db->qstr($id[$i]) . ' ORDER BY group_id'; $groups = $db->Execute($sql); while (!$groups->EOF) { $group[] = $groups->fields['group_id']; $groups->MoveNext(); } ### Verify the user has access to view this account: $delete_this = true; if (!empty($group) && is_array($group)) { for ($ix = 0; $ix < count($group); $ix++) { if (!$C_auth->auth_group_by_id($group[$ix])) { $delete_this = false; $ix = count($group); } } } unset($group); ### Verify this is not the admin account or the current user's account: if (SESS_ACCOUNT == $id[$i] || $id[$i] == '1') { $delete_this = false; } ### Generate the SQL if ($delete_this) { if ($i == 0) { $id_list .= " id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; $account_id_list .= " account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; $discount_id_list .= " account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; $ii++; } else { $id_list .= " OR id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; $account_id_list .= " OR account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; $discount_id_list .= " OR account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; $ii++; } #################################################################### ### Do any db_mapping #################################################################### $dbsql = "SELECT username FROM " . AGILE_DB_PREFIX . "account WHERE\n\t\t\t\t\t\t\t site_id = " . $db->qstr(DEFAULT_SITE) . " AND\n\t\t\t\t\t\t\t id = " . $db->qstr($id[$i]); $resultdb = $db->Execute($dbsql); $old_username = $resultdb->fields['username']; if ($C_list->is_installed('db_mapping')) { include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php'; $db_map = new db_mapping(); $db_map->account_delete($id[$i], $old_username); } } } } $db =& DB(); if ($ii > 0) { # generate the full query (account) $q = "DELETE FROM " . AGILE_DB_PREFIX . "account\n\t\t\t\t WHERE {$id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $result = $db->Execute($q); # generate the full query (sessions) $q = "DELETE FROM " . AGILE_DB_PREFIX . "session\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (account_billing) $q = "DELETE FROM " . AGILE_DB_PREFIX . "account_billing\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (account_group) $q = "DELETE FROM " . AGILE_DB_PREFIX . "account_group\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (cart) $q = "DELETE FROM " . AGILE_DB_PREFIX . "cart\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (search) $q = "DELETE FROM " . AGILE_DB_PREFIX . "search\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (staff) $q = "DELETE FROM " . AGILE_DB_PREFIX . "staff\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (ticket) if ($C_list->is_installed('ticket')) { $q = "SELECT id FROM " . AGILE_DB_PREFIX . "ticket\n\t\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $ticket = $db->Execute($q); if ($ticket != false && $ticket->RecordCount() > 0) { while (!$ticket->EOF) { include_once PATH_MODULES . 'ticket/ticket.inc.php'; $tk = new ticket(); $arr['id'] = $ticket->fields['id']; $tk->delete($arr, $tk); $ticket->MoveNext(); } } } # generate the full query (affiliate) if ($C_list->is_installed('affiliate')) { $q = "DELETE FROM " . AGILE_DB_PREFIX . "affiliate\n\t\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); } # generate the full query (discount) $q = "DELETE FROM " . AGILE_DB_PREFIX . "discount\n\t\t\t\t WHERE {$discount_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $db->Execute($q); # generate the full query (invoice) $q = "SELECT id FROM " . AGILE_DB_PREFIX . "invoice\n\t\t\t\t WHERE {$account_id_list} AND site_id = " . $db->qstr(DEFAULT_SITE); $invoice = $db->Execute($q); if ($invoice != false && $invoice->RecordCount() > 0) { while (!$invoice->EOF) { include_once PATH_MODULES . 'invoice/invoice.inc.php'; $inv = new invoice(); $arr['id'] = $invoice->fields['id']; $inv->delete($arr, $inv); $invoice->MoveNext(); } } # error reporting if ($result === false) { global $C_debug; $C_debug->error('account_admin.inc.php', 'delete', $db->ErrorMsg()); } else { # Alert delete message global $C_debug, $C_translate; $C_translate->value["CORE"]["module_name"] = $C_translate->translate('name', 'account_admin', ""); $message = $C_translate->translate('alert_delete_ids', "CORE", ""); $C_debug->alert($message); } } }
public function run() { global $db; $today = date('Y-m-d'); $cron = new cron(); $data = $cron->select_crons_to_run(); $return['cron_message'] = "Cron started"; $number_of_crons_run = "0"; $cron_log = new cronlog(); $cron_log->run_date = $today; foreach ($data as $key => $value) { $cron->domain_id = $value['domain_id']; $cron_log->cron_id = $value['id']; $cron_log->domain_id = $domain_id = $value['domain_id']; $check_cron_log = $cron_log->check(); $i = "0"; if ($check_cron_log == 0) { //only proceed if cron has not been run for today $run_cron = false; $start_date = date('Y-m-d', strtotime($value['start_date'])); $end_date = $value['end_date']; // Seconds in a day = 60 * 60 * 24 = 86400 $diff = number_format((strtotime($today) - strtotime($start_date)) / 86400, 0); //only check if diff is positive if ($diff >= 0 and ($end_date == "" or $end_date >= $today)) { if ($value['recurrence_type'] == 'day') { $modulus = $diff % $value['recurrence']; if ($modulus == 0) { $run_cron = true; } else { #$return .= "cron does not runs TODAY-days"; } } if ($value['recurrence_type'] == 'week') { $period = 7 * $value['recurrence']; $modulus = $diff % $period; if ($modulus == 0) { $run_cron = true; } else { #$return .= "cron is not runs TODAY-week"; } } if ($value['recurrence_type'] == 'month') { $start_day = date('d', strtotime($value['start_date'])); $start_month = date('m', strtotime($value['start_date'])); $start_year = date('Y', strtotime($value['start_date'])); $today_day = date('d'); $today_month = date('m'); $today_year = date('Y'); $months = $today_month - $start_month + 12 * ($today_year - $start_year); $modulus = $months % $value['recurrence']; if ($modulus == 0 and $start_day == $today_day) { $run_cron = true; } else { #$return .= "cron is not runs TODAY-month"; } } if ($value['recurrence_type'] == 'year') { $start_day = date('d', strtotime($value['start_date'])); $start_month = date('m', strtotime($value['start_date'])); $start_year = date('Y', strtotime($value['start_date'])); $today_day = date('d'); $today_month = date('m'); $today_year = date('Y'); $years = $today_year - $start_year; $modulus = $years % $value['recurrence']; if ($modulus == 0 and $start_day == $today_day and $start_month == $today_month) { $run_cron = true; } else { #$return .= "cron is not runs TODAY-year"; } } //run the recurrence for this invoice if ($run_cron) { $number_of_crons_run++; $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " was run today :: Info diff=" . $diff; $i++; $ni = new invoice(); $ni->id = $value['invoice_id']; $ni->domain_id = $domain_id; // $domain_id gets propagated from invoice to be copied from $new_invoice_id = $ni->recur(); //insert into cron_log date of run //$cron_log = new cronlog(); //$cron_log->run_date = $today; //$cron_log->domain_id = $domain_id; //$cron_log->cron_id = $value['cron_id']; $cron_log->insert(); ## email the people $invoiceobj = new invoice(); $invoice = $invoiceobj->select($new_invoice_id, $domain_id); $preference = getPreference($invoice['preference_id'], $domain_id); $biller = getBiller($invoice['biller_id'], $domain_id); $customer = getCustomer($invoice['customer_id'], $domain_id); #print_r($customer); #create PDF nameVj $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name_invoice = $spc2us_pref . ".pdf"; // email invoice if ($value['email_biller'] == "1" or $value['email_customer'] == "1") { $export = new export(); $export->domain_id = $domain_id; $export->format = "pdf"; $export->file_location = 'file'; $export->module = 'invoice'; $export->id = $invoice['id']; $export->execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email = new email(); $email->domain_id = $domain_id; $email->format = 'cron_invoice'; $email_body = new email_body(); $email_body->email_type = 'cron_invoice'; $email_body->customer_name = $customer['name']; $email_body->invoice_name = $invoice['index_name']; $email_body->biller_name = $biller['name']; $email->notes = $email_body->create(); $email->from = $biller['email']; $email->from_friendly = $biller['name']; $email->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']); $email->invoice_name = $invoice['index_name']; $email->subject = $email->set_subject(); $email->attachment = $pdf_file_name_invoice; $return['email_message'] = $email->send(); } //Check that all details are OK before doing the eway payment $eway_check = new eway(); $eway_check->domain_id = $domain_id; $eway_check->invoice = $invoice; $eway_check->customer = $customer; $eway_check->biller = $biller; $eway_check->preference = $preference; $eway_pre_check = $eway_check->pre_check(); //do eway payment if ($eway_pre_check == 'true') { // input customerID, method (REAL_TIME, REAL_TIME_CVN, GEO_IP_ANTI_FRAUD) and liveGateway or not $eway = new eway(); $eway->domain_id = $domain_id; $eway->invoice = $invoice; $eway->biller = $biller; $eway->customer = $customer; $payment_done = $eway->payment(); $payment_id = $db->lastInsertID(); $pdf_file_name_receipt = 'payment' . $payment_id . '.pdf'; if ($payment_done == 'true') { //do email of receipt to biller and customer if ($value['email_biller'] == "1" or $value['email_customer'] == "1") { /* * If you want a new copy of the invoice being emailed to the customer * use this code */ $export_rec = new export(); $export_rec->domain_id = $domain_id; $export_rec->format = "pdf"; $export_rec->file_location = 'file'; $export_rec->module = 'invoice'; $export_rec->id = $invoice['id']; $export_rec->execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email_rec = new email(); $email_rec->domain_id = $domain_id; $email_rec->format = 'cron_invoice'; $email_body_rec = new email_body(); $email_body_rec->email_type = 'cron_invoice_receipt'; $email_body_rec->customer_name = $customer['name']; $email_body_rec->invoice_name = $invoice['index_name']; $email_body_rec->biller_name = $biller['name']; $email_rec->notes = $email_body_rec->create(); $email_rec->from = $biller['email']; $email_rec->from_friendly = $biller['name']; $email_rec->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']); $email_rec->invoice_name = $invoice['index_name']; $email_rec->attachment = $pdf_file_name_invoice; $email_rec->subject = $email_rec->set_subject('invoice_eway_receipt'); $return['email_message'] = $email_rec->send(); /* * If you want a receipt as PDF being emailed to the customer * uncomment the code below */ /* $export = new export(); $export -> format = "pdf"; $export -> file_location = 'file'; $export -> module = 'payment'; $export -> id = $payment_id; $export -> execute(); $email = new email(); $email -> format = 'cron_payment'; $email_body = new email_body(); $email_body->email_type = 'cron_payment'; $email_body->customer_name = $customer['name']; $email_body->invoice_name = 'payment'.$payment_id; $email_body->biller_name = $biller['name']; $email -> notes = $email_body->create(); $email -> from = $biller['email']; $email -> from_friendly = $biller['name']; if($value['email_customer'] == "1") { $email -> to = $customer['email']; } if($value['email_biller'] == "1" AND $value['email_customer'] == "1") { $email -> to = $customer['email'].";".$biller['email']; } if($value['email_biller'] == "1" AND $value['email_customer'] == "0") { $email -> to = $customer['email']; } $email -> subject = $pdf_file_name_receipt." from ".$biller['name']; $email -> attachment = $pdf_file_name_receipt; $return['email_message'] = $email->send(); */ } } else { //do email to biller/admin - say error $email = new email(); $email->domain_id = $domain_id; $email->format = 'cron_payment'; $email->from = $biller['email']; $email->from_friendly = $biller['name']; $email->to = $biller['email']; $email->subject = "Payment failed for " . $invoice['index_name']; $error_message = "Invoice: " . $invoice['index_name'] . "<br /> Amount: " . $invoice['total'] . " <br />"; foreach ($eway->get_message() as $key => $value) { $error_message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}"; } $email->notes = $error_message; $return['email_message'] = $email->send(); } } } else { //cron not run for this cron_id $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff; } } else { //days diff is negative - whats going on $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: - Not cheduled for today - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff; } } else { // cron has already been run for that cron_id today $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron has already been run for domain: " . $domain_id . " for the date: " . $today . " for invoice " . $value['invoice_id']; $return['email_message'] = ""; } } // no crons scheduled for today if ($number_of_crons_run == '0') { $return['id'] = $i; $return['cron_message'] = "No invoices recurred for this cron run for domain: " . $domain_id . " for the date: " . $today; $return['email_message'] = ""; } //insert into cron_log date of run /* $cron_log = new cronlog(); $cron_log->run_date = $today; $cron_log->domain_id = $domain_id; $cron_log->insert(); */ /* * If you want to get an email once cron has been run edit the below details * */ /* $email = new email(); $email -> format = 'cron'; #$email -> notes = $return; $email -> from = "simpleinvoices@localhost"; $email -> from_friendly = "Simple Invoices - Cron"; $email -> to = "simpleinvoices@localhost"; #$email -> bcc = $_POST['email_bcc']; $email -> subject = "Cron for Simple Invoices has been run for today:"; $email -> send (); */ return $return; }
function invoice_cleanup($VAR) { # Load the account admin class include_once PATH_MODULES . 'invoice/invoice.inc.php'; $invoice = new invoice(); $exp = time() - 86400 * AGILE_INVOICE_CLEANUP_DAYS; # Get each account: $db =& DB(); $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'invoice WHERE process_status = ' . $db->qstr(0) . ' AND billing_status = ' . $db->qstr(0) . ' AND billed_amt <= ' . $db->qstr(0) . ' AND date_last <= ' . $db->qstr($exp) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $rs = $db->Execute($sql); while (!$rs->EOF) { $arr['id'] = $rs->fields['id']; $invoice->delete($arr, $invoice); $rs->MoveNext(); } }