예제 #1
0
function calc_invoice_items($invoice_id)
{
    $invoice = get_invoice($invoice_id);
    $ci =& get_instance();
    //total
    $ci->db->where('status', 1);
    $ci->db->where('invoice_id', $invoice_id);
    $ci->db->select_sum('total');
    $total = $ci->db->get('invoice_items')->row_array();
    //tax
    $ci->db->where('status', 1);
    $ci->db->where('invoice_id', $invoice_id);
    $ci->db->select_sum('tax');
    $tax = $ci->db->get('invoice_items')->row_array();
    //sub_total
    $ci->db->where('status', 1);
    $ci->db->where('invoice_id', $invoice_id);
    $ci->db->select_sum('sub_total');
    $sub_total = $ci->db->get('invoice_items')->row_array();
    //sub_total
    $ci->db->where('status', 1);
    $ci->db->where('invoice_id', $invoice_id);
    $ci->db->select_sum('quantity');
    $quantity = $ci->db->get('invoice_items')->row_array();
    $ci->db->where('id', $invoice_id);
    if ($invoice['in_out'] == 0) {
        $ci->db->update('invoices', array('total' => '-' . $total['total'], 'tax' => '-' . $tax['tax'], 'grand_total' => '-' . $sub_total['sub_total'], 'quantity' => $quantity['quantity']));
    } else {
        $ci->db->update('invoices', array('total' => $total['total'], 'tax' => $tax['tax'], 'grand_total' => $sub_total['sub_total'], 'quantity' => $quantity['quantity']));
    }
}
예제 #2
0
 /**
  * 
  * @global type $wpi_settings
  * @param type $user_object
  */
 static function metabox($user_object)
 {
     global $wpi_settings;
     foreach ($user_object['user_invoices'] as $single_invoice) {
         $single_invoice = get_invoice($single_invoice->ID);
         $print[$single_invoice['post_status']][] = '<li><a href="' . admin_url("admin.php?page=wpi_page_manage_invoice&wpi[existing_invoice][invoice_id]={$single_invoice['ID']}") . '">' . $single_invoice['post_title'] . '</a></li>';
     }
     $status_names = apply_filters('wpi_invoice_statuses', $wpi_settings['invoice_statuses']);
     foreach ($print as $invoice_status => $invoice_list) {
         $status_label = $status_names[$invoice_status] ? $status_names[$invoice_status] : $invoice_status;
         if (is_array($invoice_list)) {
             echo '<b>' . $status_label . '</b><ul>' . implode('', $invoice_list) . '</ul>';
         }
     }
 }
예제 #3
0
파일: index.php 프로젝트: elecnix/famesy
<?php

require_once "../../functions.php";
require_once "../../config.php";
header("Content-Type: text/html; charset=utf-8");
$i = $_REQUEST['i'];
if (!$i) {
    die("Missing invoice ID");
}
$invoice = get_invoice($i);
if (!$invoice) {
    die("Invoice not found");
}
$member = get_member($invoice['member_id']);
$reminder_type = $_REQUEST['type'];
if ($reminder_type == "expiry") {
    send_expiry_notice_email($member, $invoice);
    echo "Membre " . $member['full_name'] . " notifié de l'expiration de son adhésion.";
} else {
    echo "Invalid reminder type.";
}
?>

  /**
   * Convert a string into a number. Allow invoice ID to be passed for currency symbol localization
   *
   * @since 3.0
   *
   */
  static function currency_format($amount, $invoice_id = false) {
    global $wpi_settings;

    if ($invoice_id) {
      $invoice = get_invoice($invoice_id);
    }

    $currency_symbol = !empty($wpi_settings['currency']['symbol'][$invoice['default_currency_code']]) ? $wpi_settings['currency']['symbol'][$invoice['default_currency_code']] : '$';

    $amount = (float) $amount;

    return $currency_symbol . number_format($amount, 2, '.', ',');
  }
예제 #5
0
$cart_order_id = $_GET['cart_order_id'];
$registry = new Registry();
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('session', new Session());
if ($registry->get('session')->data['token'] != $_GET['token']) {
    echo "Wystąpił problem. Zaloguj się ponownie.";
} else {
    $order_summary = get_order_summary($cart_order_id);
    verify_order_exists($order_summary);
    $order_details = get_order_details($cart_order_id);
    $wysylka = false;
    if (isset($_GET['Wysylkowa']) && $_GET['Wysylkowa'] == '1') {
        $wysylka = true;
    }
    $order_summary = $order_summary;
    $order_data = get_order_data($cart_order_id);
    $customer = get_order_customer($order_data);
    if (can_process_request_for_invoice_generation($cart_order_id)) {
        $invoice = get_invoice($order_summary, $customer, $wysylka);
        add_invoice_note($invoice, $cart_order_id);
        add_invoice_positions($invoice, $order_details);
        add_invoice_ship_position($invoice, $order_summary);
        weryfikuj_fakture_pod_katem_zgodnosci_zaokraglen($invoice);
        handle_invoice_generation($cart_order_id, $invoice);
    } else {
        if (can_process_request_for_pro_forma_generation($cart_order_id)) {
        } else {
            throw new Exception('not authorized to perform operation');
        }
    }
}
예제 #6
0
 /**
  * Handles validation when somebody is attempting to view an invoice.
  * If validation is passsed, we add the necessary
  * filters to display the invoice header and page content;
  * Global $invoice_id variable set by WPI_Functions::validate_page_hash();
  */
 function template_redirect()
 {
     global $invoice_id, $wpi_settings, $wpi_invoice_object, $post, $current_user;
     //** Alwys load styles without checking if given page has an invoice */
     wp_enqueue_style('wpi-theme-specific');
     wp_enqueue_style('wpi-default-style');
     //** Determine if the current page is invoice's page */
     if (empty($post->ID) || $wpi_settings['web_invoice_page'] != $post->ID) {
         return;
     }
     //** If invoice_id is passed, run validate_page_hash  to make sure this is the right page and invoice_id exists */
     if (isset($_GET['invoice_id'])) {
         if (WPI_Functions::validate_page_hash(esc_sql($_GET['invoice_id']))) {
             //** load global invoice object */
             $post_id = wpi_invoice_id_to_post_id($invoice_id);
             $wpi_invoice_object = new WPI_Invoice();
             $wpi_invoice_object->load_invoice("id={$post_id}");
             add_filter('viewable_invoice_types', array($this, 'viewable_types'));
             //** Determine if current invoice object is "viewable" */
             if (!in_array($wpi_invoice_object->data['post_status'], apply_filters('viewable_invoice_types', array('active')))) {
                 return;
             }
             if (isset($wpi_settings['logged_in_only']) && $wpi_settings['logged_in_only'] == 'true') {
                 if (!current_user_can(WPI_UI::get_capability_by_level($wpi_settings['user_level'])) && !WPI_Functions::user_is_invoice_recipient($wpi_invoice_object)) {
                     //** Show 404 when invoice doesn't exist */
                     $not_found = get_query_template('404');
                     require_once $not_found;
                     die;
                 }
             }
             //** Load front end scripts */
             wp_enqueue_script('jquery.validate');
             wp_enqueue_script('wpi-gateways');
             wp_enqueue_script('jquery.maskedinput');
             wp_enqueue_script('wpi-frontend-scripts');
             if (!empty($wpi_settings['ga_event_tracking']) && $wpi_settings['ga_event_tracking']['enabled'] == 'true') {
                 wp_enqueue_script('wpi-ga-tracking', WPI_URL . "/core/js/wpi.ga.tracking.js", array('jquery'));
             }
             //** Apply Filters to the invoice description */
             add_action('wpi_description', 'wpautop');
             add_action('wpi_description', 'wptexturize');
             add_action('wpi_description', 'shortcode_unautop');
             add_action('wpi_description', 'convert_chars');
             add_action('wpi_description', 'capital_P_dangit');
             //** Declare the variable that will hold our AJAX url for JavaScript purposes */
             wp_localize_script('wpi-gateways', 'wpi_ajax', array('url' => admin_url('admin-ajax.php')));
             add_action('wp_head', array('WPI_UI', 'frontend_header'));
             if ($wpi_settings['replace_page_title_with_subject'] == 'true' || $wpi_settings['hide_page_title'] == 'true') {
                 add_action('wp_title', array('WPI_UI', 'wp_title'), 0, 3);
             }
             if ($wpi_settings['replace_page_heading_with_subject'] == 'true' || $wpi_settings['hide_page_title'] == 'true') {
                 add_action('the_title', array('WPI_UI', 'the_title'), 0, 2);
             }
             add_action('the_content', array('WPI_UI', 'the_content'), 20);
         } else {
             //** Show 404 when invoice doesn't exist */
             $not_found = get_query_template('404');
             require_once $not_found;
             die;
         }
     }
     //** Fixed WordPress filters if page is being opened in HTTPS mode */
     if (isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on") {
         if (function_exists('force_ssl')) {
             add_filter('option_siteurl', 'force_ssl');
             add_filter('option_home', 'force_ssl');
             add_filter('option_url', 'force_ssl');
             add_filter('option_wpurl', 'force_ssl');
             add_filter('option_stylesheet_url', 'force_ssl');
             add_filter('option_template_url', 'force_ssl');
             add_filter('script_loader_src', 'force_ssl');
         }
     }
     //** Lookup functionality */
     if (isset($_POST['wp_invoice_lookup_input'])) {
         if (!empty($current_user->ID)) {
             $id = get_invoice_id($_POST['wp_invoice_lookup_input']);
             if (empty($id)) {
                 //** Show 404 when invoice doesn't exist */
                 $not_found = get_query_template('404');
                 require_once $not_found;
                 die;
             }
             $invoice = get_invoice($id);
             if (current_user_can('level_10') || $current_user->data->user_email == $invoice['user_email']) {
                 header("location:" . get_invoice_permalink($_POST['wp_invoice_lookup_input']));
                 die;
             } else {
                 //** Show 404 when invoice doesn't exist */
                 $not_found = get_query_template('404');
                 require_once $not_found;
                 die;
             }
         } else {
             //** Show 404 when invoice doesn't exist */
             $not_found = get_query_template('404');
             require_once $not_found;
             die;
         }
     }
 }
예제 #7
0
function create_invoice_reference($invoiceid)
{
    $invariant = 1000;
    if (!get_invoice($invoiceid, 'reference')->reference) {
        while ($invariant-- && !set_new_invoice_reference($invoiceid)) {
        }
    }
}
예제 #8
0
    $plus_content = '
			<div class="bs-callout bs-callout-danger">
      			<h4>' . get_lang('Product Card') . ': <a href="' . site_url('account/get_account/' . $account['id']) . '" target="_blank">' . $account['name'] . '</a> <small>' . $account['county'] . '/' . $account['city'] . '</small></h4>
				
				<small><strong>' . get_lang('phone') . '</strong>:' . $account['phone'] . '  <strong>' . get_lang('gsm') . '</strong>:' . $account['gsm'] . '</small>
				<br />
      			<ul>
	  				<li>' . get_lang('Barcode Code') . ': <code>' . $account['code'] . '</code></li>
					<li>' . get_lang('Balance') . ': <code>' . get_account_balance($account['balance']) . '</code></li>
				</ul>
			</div>
			<br />';
    $custom_title = get_lang('Account Card') . ': ' . $account['name'];
}
if (isset($_GET['invoice_id'])) {
    $invoice = get_invoice($_GET['invoice_id']);
    $account = get_account(array('id' => $invoice['account_id']));
    $plus_content = '
			<div class="bs-callout bs-callout-danger">
      			<h4>' . get_lang('Invoice') . ': <a href="' . site_url('invoice/view/' . $invoice['id']) . '" target="_blank">#' . $invoice['id'] . '</a> / <small>' . $account['name'] . '</small></h4>
				<br />
      			<ul>
					<li>' . get_lang('Invoice') . ': <code><a href="' . site_url('invoice/view/' . $invoice['id']) . '" target="_blank">#' . $invoice['id'] . '</a></code></li>
	  				<li>' . get_lang('Account Card') . ': <code><a href="' . site_url('account/get_account/' . $account['id']) . '" target="_blank">' . $account['code'] . '</a></code></li>
					<li>' . get_lang('Grand Total') . ': <code>' . get_account_balance($invoice['grand_total']) . '</code></li>
				</ul>
			';
    $this->db->where('status', 1);
    $this->db->where('invoice_id', $invoice['id']);
    $items = $this->db->get('invoice_items')->result_array();
    $plus_content = $plus_content . '
예제 #9
0

<?php 
if (isset($_GET['status'])) {
    change_status_invoice($invoice_id, array('status' => $_GET['status']));
    $data['type'] = 'invoice';
    $data['invoice_id'] = $invoice['id'];
    $data['account_id'] = $invoice['account_id'];
    $data['title'] = get_lang('Invoice');
    if ($_GET['status'] == 0) {
        $data['description'] = get_lang('Deleted Payment.');
    } else {
        $data['description'] = get_lang('Activated bill again.');
    }
    add_log($data);
    $invoice = get_invoice($invoice_id);
}
?>

<?php 
if ($invoice['status'] == 0) {
    ?>
	<?php 
    alertbox('alert-danger', get_lang('Deleted Payment.'), '', false);
}
?>


<ul id="myTab" class="nav nav-tabs">
    <li class="active"><a href="#transactions" data-toggle="tab"><?php 
lang('Transactions');
    /**
     * Returns notification email based on pased values
     * 
     * @global object $wpdb
     * @global array $wpi_settings 
     */
    function get_notification_email() {
      global $wpdb, $wpi_settings, $invoice;

      require_once WPI_Path.'/core/wpi_template_functions.php';
      
      $template_id = intval($_REQUEST['template_id']);
      $invoice_id = intval($_REQUEST['wpi_invoiceid']);

      $invoice = get_invoice(wpi_invoice_id_to_post_id($invoice_id));
      $currency_symbol = (!empty($wpi_settings['currency']['symbol'][$invoice['default_currency_code']]) ? $wpi_settings['currency']['symbol'][$invoice['default_currency_code']] : "$");
      $invoice_id = (!empty($invoice['meta']['custom_id']) ? $invoice['meta']['custom_id'] : $invoice['invoice_id']);

      //** Get creator user data */
      $creator = get_userdata( $invoice['post_author'] );
      
      //** Due Date */
      $due_date = get_due_date( $invoice );
      $due_date = $due_date ? $due_date : __('Due date is not set', WPI);
      
      //** Load Templates */
      $template_array = apply_filters('wpi_email_templates', $wpi_settings['notification']);

      $ary['NotificationContent'] = $template_array[$template_id]['content'];
      
      //**
      // Tags which can be used in Content of notification email 
      //*/

      //** Invoice ID */
      $ary['NotificationContent'] = str_replace("%invoice_id%", $invoice_id, $ary['NotificationContent']);

      //** Format description */
      $desc = (!empty($invoice['post_content']) ? strip_tags( $invoice['post_content'] ) : __("No description given.", WPI));
      $ary['NotificationContent'] = str_replace("%description%", $desc, $ary['NotificationContent']);

      //** Recipient name */
      $ary['NotificationContent'] = str_replace("%recipient%", recipients_name(array('return'=>true)), $ary['NotificationContent']);

      //** Invoice link */
      $ary['NotificationContent'] = str_replace("%link%", get_invoice_permalink($invoice['invoice_id']), $ary['NotificationContent']);

      //** Invoice balance */
      $ary['NotificationContent'] = str_replace("%amount%", $currency_symbol . wp_invoice_currency_format($invoice['net']), $ary['NotificationContent']);

      //** Invoice subject/title */
      $ary['NotificationContent'] = str_replace("%subject%", $invoice['post_title'], $ary['NotificationContent']);

      //** Business name according to business settings */
      $ary['NotificationContent'] = str_replace("%business_name%", $wpi_settings['business_name'], $ary['NotificationContent']);

      //** Business email according to business settings */
      $ary['NotificationContent'] = str_replace("%business_email%", $wpi_settings['email_address'], $ary['NotificationContent']);

      //** Invoice creator name */
      $ary['NotificationContent'] = str_replace("%creator_name%", $creator->display_name, $ary['NotificationContent']);

      //** Invoice creator email */
      $ary['NotificationContent'] = str_replace("%creator_email%", $creator->user_email, $ary['NotificationContent']);

      //** Invoice Due Date */ 
      $ary['NotificationContent'] = str_replace("%due_date%", $due_date, $ary['NotificationContent']);

      //** @todo: Recurring */
      $ary['NotificationContent'] = str_replace("%recurring%", '', $ary['NotificationContent']);

      $ary['NotificationSubject'] = $template_array[$template_id]['subject'];

      //**
      // Tags which can be used in Subject of notification email 
      //*/

      //** Invoice ID */
      $ary['NotificationSubject'] = str_replace("%invoice_id%",$invoice_id,$ary['NotificationSubject']);

      //** Recipients name */
      $ary['NotificationSubject'] = str_replace("%recipient%",$invoice['user_data']['display_name'],$ary['NotificationSubject']);

      //** Invoice balance */
      $ary['NotificationSubject'] = str_replace("%amount%",$invoice['net'],$ary['NotificationSubject']);

      //** Invoice subject/title */
      $ary['NotificationSubject'] = str_replace("%subject%",$invoice['post_title'],$ary['NotificationSubject']);

      $aryJson = array();
      //** Filter data before using. korotkov@ud */
      $aryJson['wpi_content'] = apply_filters('wpi_notification_content', $ary['NotificationContent'], $invoice);
      $aryJson['wpi_subject'] = apply_filters('wpi_notification_subject', $ary['NotificationSubject'], $invoice);

      die(json_encode($aryJson));
    }
            $mform->addElement('static', $ppfield, get_string($ppfield, 'block_iomad_commerce'));
        }
        $this->add_action_buttons();
    }
}
$returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
$invoiceid = required_param('id', PARAM_INTEGER);
$context = context_system::instance();
require_login();
$PAGE->set_context($context);
$urlparams = array();
if ($returnurl) {
    $urlparams['returnurl'] = $returnurl;
}
$companylist = new moodle_url('/blocks/iomad_commerce/orderlist.php', $urlparams);
$invoice = get_invoice($invoiceid);
iomad::require_capability('block/iomad_commerce:admin_view', $context);
// Correct the navbar.
// Set the name for the page.
$linktext = get_string('orders', 'block_iomad_commerce');
// Set the url.
$linkurl = new moodle_url('/blocks/iomad_commerce/orderlist.php');
// Build the nav bar.
company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl);
$PAGE->navbar->add(get_string('edit_invoice', 'block_iomad_commerce'));
$blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_commerce', 'block', 'edit_invoice');
$blockpage->setup($urlparams);
require_login(null, false);
// Adds to $PAGE, creates $OUTPUT.
$mform = new order_edit_form($PAGE->url, $invoiceid);
$mform->set_data($invoice);
예제 #12
0
function validate_invoice($user_id, $ivi)
{
    $invoice = get_invoice(get_id($ivi), $user_id);
    return is_null($invoice) ? false : new Invoice($invoice);
}
예제 #13
0
/**
 * @return the created invoice.
 */
function create_invoice($member)
{
    $membership_type_info = get_membership_info_from_id($member['membership_type_id']);
    //    $membership_type_info = get_membership_info($member['type']);
    $amount = $membership_type_info['amount'];
    //$amount = config("amount");
    if (!$amount) {
        die("Can't get amount of membership for member #" . $member['id']);
    }
    $sql = "insert into invoice (\n        member_id,\n        amount,\n        date_created\n        ) values (\n        {$member['id']},\n        {$amount},\n        sysdate())";
    member_query($sql);
    $sql = "SELECT LAST_INSERT_ID() AS invoice_id";
    $rs = member_query($sql);
    $row = mysql_fetch_assoc($rs);
    $invoice_id = $row["invoice_id"];
    return get_invoice($invoice_id);
}
예제 #14
0
 /**
  * Convert a string into a number. Allow invoice ID to be passed for currency symbol localization
  *
  * @global array $wpi_settings
  *
  * @param type $amount
  * @param type $invoice_id
  *
  * @return type
  */
 static function currency_format($amount, $invoice_id = false)
 {
     global $wpi_settings;
     if ($invoice_id) {
         $invoice = get_invoice($invoice_id);
     }
     $currency_symbol = !empty($wpi_settings['currency']['symbol'][$invoice['default_currency_code']]) ? $wpi_settings['currency']['symbol'][$invoice['default_currency_code']] : '$';
     $amount = (double) $amount;
     $thousands_separator_symbol = !isset($wpi_settings['thousands_separator_symbol']) ? ',' : ($wpi_settings['thousands_separator_symbol'] == '0' ? '' : $wpi_settings['thousands_separator_symbol']);
     return $currency_symbol . number_format($amount, 2, '.', $thousands_separator_symbol);
 }