$period = '+3 month'; break; case 'yearly': $period = '+1 year'; break; default: $period = ''; } if (strtotime($currentRecurringDate) <= strtotime($currentDate)) { list($y, $m, $d) = explode('-', $last_recurring_date); $nextRecurringDate = date('Y-m-d', strtotime($period, mktime(0, 0, 0, $m, $d, $y))); } else { $nextRecurringDate = $currentRecurringDate; } if (strtotime($currentRecurringDate) == strtotime($currentDate)) { createInvoice($salesorder_id); } if (strtotime($nextRecurringDate) != strtotime($last_recurring_date)) { $adb->pquery('UPDATE vtiger_invoice_recurring_info SET last_recurring_date = ? WHERE salesorderid = ?', array($nextRecurringDate, $salesorder_id)); } } /* Function to create a new Invoice using the given Sales Order id */ function createInvoice($salesorder_id) { require_once 'include/utils/utils.php'; require_once 'modules/SalesOrder/SalesOrder.php'; require_once 'modules/Invoice/Invoice.php'; require_once 'modules/Users/Users.php'; global $log, $adb; global $current_user; // Payment duration in days
function invoiceDataCreate($salesorder_id = 0) { // Get the list of Invoice for which Recurring is enabled. global $adb, $log; $log =& LoggerManager::getLogger('RecurringInvoice'); $log->debug("invoked RecurringInvoice"); $sqlApproval = " AND sostatus = '10.承認済み' "; $sqlApproval .= " AND ( "; $sqlApproval .= " carrier = '契約' "; $sqlApproval .= " OR "; $sqlApproval .= " carrier = '契約変更' "; $sqlApproval .= " )"; $sqlApproval .= " AND (hr_claim_flag = 0 OR hr_claim_flag is null) "; /* ▼ ** ショット請求書作成 ***************/ $sql = " SELECT "; $sql .= " vtiger_salesorder.salesorderid, vtiger_salesorder.subject "; $sql .= " FROM vtiger_salesorder "; $sql .= " INNER JOIN vtiger_crmentity AS crmentity_salesorder ON vtiger_salesorder.salesorderid = crmentity_salesorder.crmid AND crmentity_salesorder.deleted = 0 "; $sql .= " left join ( "; $sql .= " SELECT `salesorderid`, `invoicedate`, `invoicestatus` FROM `vtiger_invoice` "; $sql .= " inner join `vtiger_crmentity` AS `crmentity_invoice` ON `vtiger_invoice`.`invoiceid` = `crmentity_invoice`.`crmid` AND `crmentity_invoice`.`deleted` = 0 "; $sql .= " WHERE TRUE "; $sql .= " AND `vtiger_invoice`.`invoicedate` <= '" . $_POST[end_date] . "' "; $sql .= " AND `vtiger_invoice`.`invoicedate` >= '" . $_POST[first_date] . "' "; $sql .= " ) `vtiger_invoice` ON `vtiger_salesorder`.`salesorderid` = `vtiger_invoice`.`salesorderid` "; $sql .= " WHERE TRUE "; if ($salesorder_id !== 0) { $sql .= " AND vtiger_salesorder.salesorderid = {$salesorder_id} "; } #受注ID(salesorderid) $sql .= "AND `vtiger_salesorder`.`division` = '{$_POST['division']}' "; $sql .= " AND submission_date <= '" . $_POST[end_date] . "' "; #申込日 $sql .= " AND submission_date >= '" . $_POST[first_date] . "' "; #申込日 $sql .= " AND enable_recurring = 0 "; #ストック計上有効 > 無効 $sql .= " AND ( `vtiger_invoice`.`invoicestatus` NOT IN ('上長確認済', '営業確認済') OR `vtiger_invoice`.`invoicestatus` is null) "; $sql .= $sqlApproval; print "ショット案件<br />"; print "sql : " . $sql . "<br /><br />"; $result = $adb->pquery($sql, array()); $no_of_salesorder = $adb->num_rows($result); for ($i = 0; $i < $no_of_salesorder; $i++) { $rowSalesOrder = $adb->fetch_array($result); $intSalesorderId = $rowSalesOrder[salesorderid]; print "<p>ID : " . $intSalesorderId . "</p>"; createInvoice($intSalesorderId); ob_flush(); flush(); } //End for /* ▲ ** ショット請求書作成 ***************/ /* ▼ ** 固定(ストック)・成果 請求書作成 ***************/ /* $sql =" SELECT "; $sql.=" vtiger_salesorder.salesorderid, vtiger_salesorder.subject, recurring_frequency, start_period, end_period, last_recurring_date, `invoicedate`, "; $sql.=" payment_duration_values, invoice_status FROM vtiger_salesorder "; $sql.=" INNER JOIN vtiger_crmentity AS crmentity_salesorder ON vtiger_salesorder.salesorderid = crmentity_salesorder.crmid AND crmentity_salesorder.deleted = 0 "; $sql.=" INNER JOIN vtiger_invoice_recurring_info ON vtiger_salesorder.salesorderid = vtiger_invoice_recurring_info.salesorderid "; $sql.=" INNER JOIN vtiger_invoice ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid AND vtiger_invoice.invoicestatus NOT IN ('上長確認済', '営業確認済') "; $sql.=" INNER JOIN vtiger_crmentity AS crmentity_invoice ON vtiger_invoice.invoiceid = crmentity_invoice.crmid AND crmentity_invoice.deleted = 0 "; $sql.=" WHERE TRUE "; if($salesorder_id !== 0) $sql .= " AND vtiger_salesorder.salesorderid = {$salesorder_id} "; #受注ID(salesorderid) $sql.=" AND DATE_FORMAT(start_period,'%Y-%m-%d') <= '".$_POST[end_date]."' "; #契約開始日 $sql.=" AND DATE_FORMAT(end_period,'%Y-%m-%d') >= '".$_POST[first_date]."' "; #契約終了日 $sql.=" AND enable_recurring = 1 "; #ストック計上有効 > 有効 $sql.=$sqlApproval; */ $sql = " SELECT "; $sql .= " \t`vtiger_salesorder`.`salesorderid`, `vtiger_salesorder`.`subject`, `recurring_frequency`, `start_period`, `end_period`, `last_recurring_date` "; $sql .= " \t, `vtiger_invoice`.`invoicedate`, `vtiger_invoice`.`invoicestatus` "; $sql .= " FROM `vtiger_salesorder` "; $sql .= " inner join `vtiger_crmentity` AS `crmentity_salesorder` ON `vtiger_salesorder`.`salesorderid` = `crmentity_salesorder`.`crmid` AND `crmentity_salesorder`.`deleted` = 0 "; $sql .= " inner join `vtiger_invoice_recurring_info` ON `vtiger_salesorder`.`salesorderid` = `vtiger_invoice_recurring_info`.`salesorderid` "; $sql .= " left join ( "; $sql .= " SELECT `salesorderid`, `invoicedate`, `invoicestatus` FROM `vtiger_invoice` "; $sql .= " inner join `vtiger_crmentity` AS `crmentity_invoice` ON `vtiger_invoice`.`invoiceid` = `crmentity_invoice`.`crmid` AND `crmentity_invoice`.`deleted` = 0 "; $sql .= " WHERE TRUE "; $sql .= " AND `vtiger_invoice`.`invoicedate` <= '" . $_POST[end_date] . "' "; $sql .= " AND `vtiger_invoice`.`invoicedate` >= '" . $_POST[first_date] . "' "; $sql .= " ) `vtiger_invoice` ON `vtiger_salesorder`.`salesorderid` = `vtiger_invoice`.`salesorderid` "; $sql .= " WHERE TRUE "; if ($salesorder_id !== 0) { $sql .= " AND `vtiger_salesorder`.`salesorderid` = {$salesorder_id} "; } $sql .= "AND `vtiger_salesorder`.`division` = '{$_POST['division']}' "; $sql .= " AND DATE_FORMAT(start_period,'%Y-%m-%d') <= '" . $_POST[end_date] . "' "; #契約開始日 $sql .= " AND DATE_FORMAT(end_period,'%Y-%m-%d') >= '" . $_POST[first_date] . "' "; #契約終了日 $sql .= " AND ( `vtiger_invoice`.`invoicestatus` NOT IN ('上長確認済', '営業確認済') OR `vtiger_invoice`.`invoicestatus` is null) "; $sql .= $sqlApproval; print "ストック案件<br />"; print "sql : " . $sql . "<br /><br />"; #exit; $result = $adb->pquery($sql, array()); $no_of_salesorder = $adb->num_rows($result); for ($i = 0; $i < $no_of_salesorder; $i++) { $rowSalesOrder = $adb->fetch_array($result); $intSalesorderId = $rowSalesOrder[salesorderid]; # if(($rowSalesOrder[invoicedate] >= $_POST[first_date] AND $rowSalesOrder[invoicedate] <= $_POST[end_date]) == false) continue; print "ID : " . $intSalesorderId . "<br />"; createInvoice($intSalesorderId); ob_flush(); flush(); } //End for /* ▼ ** 固定(ストック)・成果 請求書作成 ***************/ }
<?php //Collect data to send $variables = ['key' => 'free', 'option' => 'create_invoice', 'data_type' => 'json', 'name_to' => 'Contoso B.V.', 'address_to' => 'Verzonnenstraat 25', 'zip_to' => '1234 AB', 'city_to' => 'Amsterdam', 'country_to' => 'Nederland', 'logo_from' => 'https://www.factuursimpel.nl/img/logo_black_example.png', 'name_from' => 'Factuur Simpel', 'address_from' => 'Burgemeester Swartstraat 11', 'zip_from' => '1511 BH', 'city_from' => 'Oostzaan', 'country_from' => 'Nederland', 'coc_from' => '57147353', 'vat_from' => 'NL070191426B01', 'iban_from' => 'NL14INGB0007757828', 'invoice_number' => '3642', 'delivery_date' => '14-01-2016', 'invoice_date' => '16-01-2016', 'reference' => '234037', 'product_ammount' => ['1', '2', '3', '4'], 'product_description' => ['Product 1', 'Product 2', 'Product 3', 'Product 4'], 'product_price_no_vat' => ['1,00', '2,00', '3,00', '4,00'], 'product_vat_rate' => ['21', '12', '6', '0'], 'bottom_notice' => 'Wij verzoeken u vriendelijk om het factuurbedrag binnen 30 dagen na factuurdatum over te maken onder vermelding van het factuur- en klantnummer.' . '<br><br>' . 'Kijk voor meer informatie op onze website.']; header('Content-type: application/pdf'); //View PDF $result_array = json_decode(createInvoice($variables), true); echo base64_decode($result_array['invoice_data']); function createInvoice($variables) { //Urlify data $variables_string = http_build_query($variables); //Initialise Connection $curl = curl_init(); curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => 'https://www.factuursimpel.nl/api.php', CURLOPT_POST => count($variables), CURLOPT_POSTFIELDS => $variables_string, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 2]); //Receive Results $result = curl_exec($curl); curl_close($curl); //View JSON return $result; }
/** * Process payment for woocommerce checkout * * @param mixed $order_id */ function process_payment($order_id) { require 'gocoin-lib.php'; global $woocommerce, $wpdb; $coin_type = $_POST['coin_type']; $order =& new WC_Order($order_id); $order->update_status('on-hold', __('Awaiting payment notification from GoCoin.com', 'woothemes')); // invoice options if (version_compare(WOOCOMMERCE_VERSION, '2.1.0', '>=')) { // >= 2.1.0 $redirect_url = $this->get_return_url($this->order); } else { // < 2.1.0 $redirect_url = add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))); } $callback_url = get_option('siteurl') . "/?gocoin_callback=1"; $currency = get_woocommerce_currency(); $options = array('coin_type' => $coin_type, 'currency' => $currency, 'callback_url' => $callback_url, 'redirect_url' => $redirect_url, 'customer_name' => $order->billing_first_name . ' ' . $order->billing_last_name, 'customer_address_1' => $order->billing_address_1, 'customer_address_2' => $order->billing_address_2, 'customer_city' => $order->billing_city, 'customer_region' => $order->billing_state, 'customer_postal_code' => $order->billing_postcode, 'customer_country' => $order->billing_country, 'customer_phone' => $order->billing_phone, 'customer_email' => $order->billing_email); $invoice = createInvoice($order_id, $order->order_total, $options, $this->client); if (isset($invoice->error)) { $order->add_order_note(var_export($invoice['error'])); $woocommerce->add_error(__('Error creating GoCoin invoice. Please try again or try another payment method.')); } else { $url = "https://gateway.gocoin.com/merchant/" . $invoice->merchant_id . "/invoices/" . $invoice->id; $woocommerce->cart->empty_cart(); return array('result' => 'success', 'redirect' => $url); } }
<?php //Collect data to send $variables = ['key' => 'free', 'option' => 'create_invoice', 'data_type' => 'xml', 'name_to' => 'Contoso B.V.', 'address_to' => 'Verzonnenstraat 25', 'zip_to' => '1234 AB', 'city_to' => 'Amsterdam', 'country_to' => 'Nederland', 'logo_from' => 'https://www.factuursimpel.nl/img/logo_black_example.png', 'name_from' => 'Factuur Simpel', 'address_from' => 'Burgemeester Swartstraat 11', 'zip_from' => '1511 BH', 'city_from' => 'Oostzaan', 'country_from' => 'Nederland', 'coc_from' => '57147353', 'vat_from' => 'NL070191426B01', 'iban_from' => 'NL14INGB0007757828', 'invoice_number' => '3642', 'delivery_date' => '14-01-2016', 'invoice_date' => '16-01-2016', 'reference' => '234037', 'product_ammount' => ['1', '2', '3', '4'], 'product_description' => ['Product 1', 'Product 2', 'Product 3', 'Product 4'], 'product_price_no_vat' => ['1,00', '2,00', '3,00', '4,00'], 'product_vat_rate' => ['21', '12', '6', '0'], 'bottom_notice' => 'Wij verzoeken u vriendelijk om het factuurbedrag binnen 30 dagen na factuurdatum over te maken onder vermelding van het factuur- en klantnummer.' . '<br><br>' . 'Kijk voor meer informatie op onze website.']; header("Content-type: text/xml"); echo createInvoice($variables); function createInvoice($variables) { //Urlify data $variables_string = http_build_query($variables); //Initialise Connection $curl = curl_init(); curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => 'https://www.factuursimpel.nl/api.php', CURLOPT_POST => count($variables), CURLOPT_POSTFIELDS => $variables_string, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 2]); //Receive Results $result = curl_exec($curl); curl_close($curl); //View JSON return $result; }
chdir("../../common"); require_once "init.php"; chdir("../database"); require_once "storeFrontend.php"; // Get data $storeId = intval($_GET["storeId"]); $userId = $_SESSION['storesLogin'][$storeId]['userId']; $address = $_GET["address"]; setUserAddress($userId, $address); $cart = $_SESSION['storesLogin'][$storeId]['cart']; // Create order $orderId = newOrder($userId); $total = 0; foreach ($cart as $item) { $productId = $item["id"]; $quantity = $item["qt"]; $baseCost = getProduct($productId); $baseCost = $baseCost["price"]; $total += $quantity * $baseCost; addProductToOrder($orderId, $productId, $quantity, $baseCost); } // Create an invoice $code = substr(str_shuffle(md5(time())), 0, 10); $store = getStoreById($storeId); $domain = $store[0]["domain"]; $vat = $store[0]["vat"]; $total *= 1 + $vat; $id = createInvoice($code, $total, $vat, $orderId); // Clear cart $_SESSION['storesLogin'][$storeId]['cart'] = array(); header("Location: ../../pages/store/invoice.php?orderId=" . $orderId);
<?php require "../common.php"; session_start(); $db = new DB(); verifyInputData(); $user = getUserData($db); markReferral($db); if ($_POST['type'] == 'credit') { require "../modules/cccharge.php"; $amount = createAmount($user); $invoice = createInvoice(); $result = chargeCreditCard($amount, $_POST['first-name'], $_POST['last-name'], $_POST['email'], $_POST['card'], $_POST['exp'], $_POST['cvc'], $invoice); if ($result) { registerCourses($db, $user); displayConfirmation($db, $amount, $invoice); sendConfirmationEmail($db, $user, $amount, $invoice); } else { error("Unforseen Error", "Something failed in an unexpected way. Please contact the Experimental College and ask to speak with the webmaster"); } } else { registerCourses($db, $user); displayConfirmation($db, $amount, $invoice); sendConfirmationEmail($db, $user, $amount, $invoice); } $_SESSION["cart"] = null; //verifies user data, throws errors if they arent signed in, if there is no data, //if there are no classes, or if there's missing credit data function verifyInputData() { if (empty($_SESSION["id"])) {
$mail->isSMTP(); $mail->Host = $config['email']['smtphost']; $mail->SMTPAuth = $config['email']['smtpauth']; $mail->Username = $config['email']['smtpuser']; $mail->Password = $config['email']['smtppass']; $mail->SMTPSecure = $config['email']['smtpsec']; $mail->Port = $config['email']['smtpport']; $mail->setFrom($config['email']['from'], $config['email']['fromName']); $mail->addAddress($recipient); $mail->Subject = $subject; $mail->Body = $data; $mail->IsHTML(true); if (!$mail->send()) { echo 'Message could not be sent.<br>'; echo 'Mailer Error: <pre>' . $mail->ErrorInfo . '</pre>'; die; } return true; } if (!isset($_SESSION['user']) && $_SERVER['SCRIPT_NAME'] != '/login.php') { header("Location: {$domain}/login/?red=" . urlencode($_SERVER['REQUEST_URI'])); } if ($_SESSION['user_priv'] != '0') { die('Not Allowed :('); } if (isset($_POST['userdatasubmit'])) { updateUser($_POST); } if (isset($_POST['invoicesubmit'])) { createInvoice($_POST); }