Beispiel #1
1
 public static function apiUpdateOrder($order, $response)
 {
     if (!defined('ORDER_MANAGEMENT')) {
         define('ORDER_MANAGEMENT', true);
     }
     if (!empty($order['status'])) {
         $statuses = fn_get_statuses(STATUSES_ORDER, false, true);
         if (!isset($statuses[$order['status']])) {
             $response->addError('ERROR_OBJECT_UPDATE', str_replace('[object]', 'orders', __('twgadmin_wrong_api_object_data')));
         } else {
             fn_change_order_status($order['order_id'], $order['status']);
         }
     }
     $cart = array();
     fn_clear_cart($cart, true);
     $customer_auth = fn_fill_auth(array(), array(), false, 'C');
     fn_form_cart($order['order_id'], $cart, $customer_auth);
     $cart['order_id'] = $order['order_id'];
     // update only profile data
     $profile_data = fn_check_table_fields($order, 'user_profiles');
     $cart['user_data'] = fn_array_merge($cart['user_data'], $profile_data);
     $cart['user_data'] = fn_array_merge($cart['user_data'], $order);
     fn_calculate_cart_content($cart, $customer_auth, 'A', true, 'I');
     if (!empty($order['details'])) {
         db_query('UPDATE ?:orders SET details = ?s WHERE order_id = ?i', $order['details'], $order['order_id']);
     }
     if (!empty($order['notes'])) {
         $cart['notes'] = $order['notes'];
     }
     fn_update_payment_surcharge($cart, $customer_auth);
     list($order_id, $process_payment) = fn_place_order($cart, $customer_auth, 'save');
     return array($order_id, $process_payment);
 }
Beispiel #2
0
function fn_google_analytics_change_order_status(&$status_to, &$status_from, &$order_info)
{
    if (Registry::get('addons.google_analytics.track_ecommerce') == 'N' || AREA != 'A') {
        return false;
    }
    $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true, true);
    if ($order_statuses[$status_to]['params']['inventory'] == 'D' && $order_statuses[$status_from]['params']['inventory'] == 'I') {
        // decrease amount
        fn_google_anaylitics_send(fn_google_analytics_get_tracking_code($order_info['company_id']), $order_info, false);
    } elseif ($order_statuses[$status_to]['params']['inventory'] == 'I' && $order_statuses[$status_from]['params']['inventory'] == 'D') {
        // increase amount
        fn_google_anaylitics_send(fn_google_analytics_get_tracking_code($order_info['company_id']), $order_info, true);
    }
}
Beispiel #3
0
function fn_google_analytics_change_order_status($status_to, $status_from, $order_info)
{
    if (Registry::get('addons.google_analytics.track_ecommerce') == 'N') {
        return false;
    }
    $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true, true);
    if ($order_statuses[$status_to]['inventory'] == 'D' && $order_statuses[$status_from]['inventory'] == 'I') {
        // decrease amount
        fn_google_anaylitics_send(Registry::get('addons.google_analytics.tracking_code'), $order_info, false);
    } elseif ($order_statuses[$status_to]['inventory'] == 'I' && $order_statuses[$status_from]['inventory'] == 'D') {
        // increase amount
        fn_google_anaylitics_send(Registry::get('addons.google_analytics.tracking_code'), $order_info, true);
    }
}
Beispiel #4
0
 public function index($id = '', $params = array())
 {
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     $type = !empty($params['type']) ? $params['type'] : STATUSES_ORDER;
     if (!empty($id)) {
         $data = fn_get_status_by_id($id, $lang_code);
         if (empty($data)) {
             $status = Response::STATUS_NOT_FOUND;
         } else {
             $status = Response::STATUS_OK;
         }
     } else {
         $items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_elements_per_page'));
         $page = $this->safeGet($params, 'page', 1);
         $data = fn_get_statuses($type, array(), false, false, $lang_code);
         $data = array_values($data);
         if ($items_per_page) {
             $data = array_slice($data, ($page - 1) * $items_per_page, $items_per_page);
         }
         $data = array('statuses' => $data, 'params' => array('items_per_page' => $items_per_page, 'page' => $page, 'total_items' => count($data)));
         $status = Response::STATUS_OK;
     }
     return array('status' => $status, 'data' => $data);
 }
Beispiel #5
0
function fn_settings_variants_addons_rus_unisender_order_status_sms()
{
    $lists = array();
    $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true, true);
    foreach ($order_statuses as $key => $value) {
        $lists[$key] = $value['description'];
    }
    return $lists;
}
 public final function getOrderSectionsInfo($date_periods, $total_periods, $orders, $sort_by, $sort_order)
 {
     $order_sections = array();
     $section_names = array();
     $order_totals = array();
     $show_empty_sections = false;
     if ($sort_by == 'date') {
         $last_date = min($date_periods);
         foreach (array_keys($date_periods) as $period_id) {
             $section_names[$period_id] = self::getOrderPeriodName($period_id);
         }
         foreach ($orders as $order) {
             $selected_period_id = '';
             if ($order['timestamp'] > TIME) {
                 $selected_period_id = 'future';
             } elseif ($order['timestamp'] < $last_date) {
                 $selected_period_id = 'past';
             } else {
                 foreach ($date_periods as $period_id => $start_date) {
                     if ($order['timestamp'] > $start_date) {
                         $selected_period_id = $period_id;
                         break;
                     }
                 }
             }
             if ($selected_period_id != '') {
                 $order_sections[$selected_period_id][] = $order;
                 $order_totals[$selected_period_id] = isset($order_totals[$selected_period_id]) ? $order_totals[$selected_period_id] + $order['total'] : $order['total'];
             }
         }
         if (isset($order_sections['future'])) {
             $section_names = array('future' => self::getOrderPeriodName('future')) + $section_names;
         }
         if (isset($order_sections['past'])) {
             $section_names['past'] = self::getOrderPeriodName('more_than_year');
         }
         if ($sort_order == 'asc') {
             $section_names = array_reverse($section_names, true);
         }
         $show_empty_sections = true;
     } elseif ($sort_by == 'status') {
         $section_names = fn_get_statuses(STATUSES_ORDER, true);
         ksort($section_names);
         if ($sort_order == 'desc') {
             $section_names = array_reverse($section_names);
         }
         foreach ($orders as $order) {
             $selected_period_id = $order['status'];
             $order_sections[$selected_period_id][] = $order;
             $order_totals[$selected_period_id] = isset($order_totals[$selected_period_id]) ? $order_totals[$selected_period_id] + $order['total'] : $order['total'];
         }
         $show_empty_sections = true;
     } elseif ($sort_by == 'total') {
         $min_total = min($total_periods);
         $section_names = array();
         foreach ($total_periods as $subtotal) {
             $section_names['more_' . $subtotal] = __('more_than') . ' ' . fn_format_price($subtotal);
         }
         $section_names['less'] = __('less_than') . ' ' . fn_format_price($min_total);
         reset($total_periods);
         foreach ($orders as $order) {
             if ($order['total'] < $min_total) {
                 $selected_period_id = 'less';
             } else {
                 foreach ($total_periods as $subtotal) {
                     if ($order['total'] > $subtotal) {
                         $selected_period_id = 'more_' . $subtotal;
                         break;
                     }
                 }
             }
             if ($selected_period_id) {
                 $order_sections[$selected_period_id][] = $order;
                 $order_totals[$selected_period_id] = isset($order_totals[$selected_period_id]) ? $order_totals[$selected_period_id] + $order['total'] : $order['total'];
             }
         }
         if ($sort_order == 'asc') {
             $section_names = array_reverse($section_names);
         }
     }
     return array($order_sections, $section_names, $order_totals, $show_empty_sections);
 }
Beispiel #7
0
/**
 * Check if the promotion is already used by customer.
 *
 * @param int $promotion_id
 * @param array $cart
 * @return int|bool
 */
function fn_promotion_check_existence($promotion_id, &$cart)
{
    static $statuses = null;
    if (is_null($statuses)) {
        $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true);
        foreach ($order_statuses as $status) {
            if ($status['params']['inventory'] == 'D') {
                // decreasing (positive) status
                $statuses[] = $status['status'];
            }
        }
    }
    if (!$statuses) {
        return false;
    }
    $udata = $cart['user_data'];
    fn_fill_user_fields($udata);
    if (defined('ORDER_MANAGEMENT') && !empty($cart['order_id'])) {
        $order_management_condition = db_quote(' order_id != ?i AND ', $cart['order_id']);
    } else {
        $order_management_condition = '';
    }
    $exists = db_get_field("SELECT ((firstname = ?s) + (lastname = ?s) + (b_city = ?s) + (b_state = ?s) + (b_country = ?s) + (b_zipcode = ?s) + (email = ?s) * 6) as r FROM ?:orders WHERE ?p FIND_IN_SET(?i, promotion_ids) AND status IN (?a) HAVING r >= ?i LIMIT 1", $udata['firstname'], $udata['lastname'], $udata['b_city'], $udata['b_state'], $udata['b_country'], $udata['b_zipcode'], $udata['email'], $order_management_condition, $promotion_id, $statuses, PROMOTION_MIN_MATCHES);
    return $exists;
}
Beispiel #8
0
        }
        $response->returnResponse();
    }
}
if ($mode == 'post') {
    if ($_REQUEST['action'] == 'get') {
        $object_name = '';
        $condition = array();
        $options = array('lang_code' => $lang_code);
        $sortings = array();
        $result = array();
        $is_paginate = false;
        $total_items = 0;
        $items_per_page = !empty($_REQUEST['items_per_page']) ? $_REQUEST['items_per_page'] : TWG_RESPONSE_ITEMS_LIMIT;
        if ($object == 'statuses') {
            $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), false, false, $lang_code);
            $api_statuses = array();
            foreach ($order_statuses as $k => $v) {
                $status = array('code' => $k, 'description' => $v['description'], 'color' => '#28ABF6');
                if ($k == 'C' || $k == 'P') {
                    $status['color'] = '#97CF4D';
                } elseif ($k == 'D' || $k == 'F') {
                    $status['color'] = '#FF5215';
                } elseif ($k == 'I') {
                    $status['color'] = '#D2D2D2';
                } elseif ($k == 'O') {
                    $status['color'] = '#FF9522';
                }
                $api_statuses[] = $status;
            }
            $result['orders']['status'] = $api_statuses;
Beispiel #9
0
function fn_settings_variants_addons_call_requests_order_status()
{
    $data = array('' => ' -- ');
    foreach (fn_get_statuses(STATUSES_ORDER) as $status) {
        $data[$status['status']] = $status['description'];
    }
    return $data;
}
Beispiel #10
0
/**
 * Gets full information about a particular status
 * @param string $status One letter status code
 * @param string $type One letter status type
 * @param int $object_id Recurring billing: ID of an object to be checked for subscriptions
 * @param string $lang_code Language code
 * @param int $company_id Company identifier
 * @return array Status data
 */
function fn_get_status_data($status, $type, $object_id = 0, $lang_code = DESCR_SL, $company_id = 0)
{
    fn_set_hook('get_status_data_pre', $status, $type, $object_id, $lang_code, $company_id);
    if (empty($status) || empty($type)) {
        return array();
    }
    $status_data = fn_get_statuses($type, !is_array($status) ? (array) $status : $status, false, false, $lang_code, $company_id);
    $status_data = reset($status_data);
    fn_set_hook('get_status_data_post', $status_data, $status, $type, $object_id, $lang_code, $company_id);
    return $status_data;
}
Beispiel #11
0
                fn_delete_call_request($request_id);
            }
        }
    }
    if ($mode == 'delete') {
        if ($_REQUEST['request_id']) {
            fn_delete_call_request($_REQUEST['request_id']);
        }
    }
    if ($mode == 'update_status') {
        if (!empty($_REQUEST['id']) && !empty($_REQUEST['status'])) {
            db_query("UPDATE ?:call_requests SET status = ?s WHERE request_id = ?i", $_REQUEST['status'], $_REQUEST['id']);
            fn_set_notification('N', __('notice'), __('status_changed'));
        }
        if (empty($_REQUEST['return_url'])) {
            exit;
        } else {
            return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['return_url']);
        }
    }
    return array(CONTROLLER_STATUS_OK, 'call_requests.manage');
}
if ($mode == 'manage') {
    $params = array_merge(array('items_per_page' => Registry::get('settings.Appearance.admin_elements_per_page')), $_REQUEST);
    $params['company_id'] = Registry::get('runtime.company_id');
    list($call_requests, $search) = fn_get_call_requests($params, DESCR_SL);
    $statuses = db_get_list_elements('call_requests', 'status', true, DESCR_SL, 'call_requests.status.');
    $order_statuses = fn_get_statuses(STATUSES_ORDER);
    $responsibles = fn_call_requests_get_responsibles();
    Tygh::$app['view']->assign('call_requests', $call_requests)->assign('search', $search)->assign('call_request_statuses', $statuses)->assign('order_statuses', $order_statuses)->assign('responsibles', $responsibles);
}
Beispiel #12
0
function fn_gift_registry_change_order_status($status_to, $status_from, &$order_info)
{
    $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true);
    if ($order_statuses[$status_to]['inventory'] == 'D' && $order_statuses[$status_from]['inventory'] == 'I') {
        // decrease amount
        $sign = '+';
    } elseif ($order_statuses[$status_to]['inventory'] == 'I' && $order_statuses[$status_from]['inventory'] == 'D') {
        // increase amount
        $sign = '-';
    }
    if (!empty($sign)) {
        foreach ($order_info['items'] as $v) {
            if (is_array($v['extra']) && !empty($v['extra']['events'])) {
                foreach ($v['extra']['events'] as $item_id => $amount) {
                    db_query("UPDATE ?:giftreg_event_products SET ordered_amount = ordered_amount {$sign} ?i WHERE item_id = ?i", $amount, $item_id);
                }
            }
        }
    }
}
Beispiel #13
0
/**
 * Send order notification
 *
 * @param array $order_info order information
 * @param array $edp_data information about downloadable products
 * @param mixed $force_notification user notification flag (true/false), if not set, will be retrieved from status parameters
 * @return array structured data
 */
function fn_order_notification(&$order_info, $edp_data = array(), $force_notification = array())
{
    static $notified = array();
    if (!empty($notified[$order_info['order_id']][$order_info['status']]) && $notified[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) {
        return true;
    }
    if (!is_array($force_notification)) {
        $force_notification = fn_get_notification_rules($force_notification, !$force_notification);
    }
    $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true);
    $status_params = $order_statuses[$order_info['status']];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true) {
        $notified[$order_info['order_id']][$order_info['status']] = true;
        Registry::get('view_mail')->assign('order_info', $order_info);
        Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $order_info['lang_code']));
        Registry::get('view_mail')->assign('status_settings', $order_statuses[$order_info['status']]);
        $companies =& Registry::get('s_companies');
        Registry::get('view_mail')->assign('companies', $companies);
        // restore secondary currency
        if (!empty($order_info['secondary_currency']) && Registry::get("currencies.{$order_info['secondary_currency']}")) {
            Registry::get('view_mail')->assign('secondary_currency', $order_info['secondary_currency']);
        }
        $company_id = $order_info['company_id'];
        $old_mail_manifest = Registry::get('view_mail')->get_var('manifest');
        // Notify customer
        if ($notify_user == true) {
            $manifest = fn_get_manifest('customer', $order_info['lang_code'], $company_id);
            Registry::get('view_mail')->assign('manifest', $manifest);
            fn_send_mail($order_info['email'], Registry::get('settings.Company.company_newsletter_email'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $order_info['lang_code']);
            //		fn_send_mail('*****@*****.**', Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $order_info['lang_code']);
        }
        if ($notify_department == true) {
            // Translate descriptions to admin language
            fn_translate_products($order_info['items'], 'product', Registry::get('settings.Appearance.admin_default_language'));
            Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.admin_default_language')));
            $company_email = !empty($companies[$company_id]['email']) ? $companies[$company_id]['email'] : Registry::get('settings.Company.company_orders_department');
            $lang_code = Registry::get('settings.Appearance.admin_default_language');
            $manifest = fn_get_manifest('customer', $lang_code, $company_id);
            Registry::get('view_mail')->assign('manifest', $manifest);
            fn_send_mail($company_email, Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $lang_code, $order_info['email']);
            if (Registry::get('settings.Suppliers.notify_order_department') == 'Y') {
                Registry::get('view_mail')->assign('manifest', $old_mail_manifest);
                fn_send_mail(Registry::get('settings.Company.company_orders_department'), Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $lang_code, $order_info['email']);
            }
        }
        Registry::get('view_mail')->assign('manifest', $old_mail_manifest);
        if (!empty($edp_data) && $notify_user == true) {
            Registry::get('view_mail')->assign('edp_data', $edp_data);
            fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'orders/edp_access_subj.tpl', 'orders/edp_access.tpl', '', $order_info['lang_code']);
        }
    }
    if (!empty($edp_data) && !$notify_user) {
        // Send out download links for EDP with "Immediately" Activation mode
        // TRUE if the EDP download links e-mail has already been sent. Used to avoid sending duplicate e-mails.
        $download_email_sent = false;
        foreach ($edp_data as $edp_item) {
            foreach ($edp_item['files'] as $file) {
                if (!empty($file['activation']) && $file['activation'] == 'I' && !$download_email_sent) {
                    Registry::get('view_mail')->assign('edp_data', $edp_data);
                    Registry::get('view_mail')->assign('order_info', $order_info);
                    fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'orders/edp_access_subj.tpl', 'orders/edp_access.tpl', '', $order_info['lang_code']);
                    $download_email_sent = true;
                    break;
                }
            }
        }
    }
    if (PRODUCT_TYPE == 'PROFESSIONAL') {
        fn_companies_suppliers_order_notification($order_info, $order_statuses, $force_notification);
    }
    fn_set_hook('order_notification', $order_info, $order_statuses, $force_notification);
}
Beispiel #14
0
     }
     // Update file downloads section
     if (!empty($_REQUEST['edp_downloads'])) {
         foreach ($_REQUEST['edp_downloads'] as $ekey => $v) {
             foreach ($v as $file_id => $downloads) {
                 $max_downloads = db_get_field("SELECT max_downloads FROM ?:product_files WHERE file_id = ?i", $file_id);
                 if (!empty($max_downloads)) {
                     db_query('UPDATE ?:product_file_ekeys SET ?u WHERE ekey = ?s', array('downloads' => $max_downloads - $downloads), $ekey);
                 }
             }
         }
     }
     $suffix = ".details?order_id={$_REQUEST['order_id']}";
 }
 if ($mode == 'bulk_print' && !empty($_REQUEST['order_ids'])) {
     $view_mail->assign('order_status_descr', fn_get_statuses(STATUSES_ORDER, true, true, true));
     $html = array();
     foreach ($_REQUEST['order_ids'] as $k => $v) {
         $view_mail->assign('order_info', fn_get_order_info($v));
         if (DISPATCH_EXTRA == 'pdf') {
             $html[] = $view_mail->display('orders/print_invoice.tpl', false);
         } else {
             $view_mail->display('orders/print_invoice.tpl');
             echo "<div style='page-break-before: always;'>&nbsp;</div>";
         }
     }
     if (DISPATCH_EXTRA == 'pdf') {
         fn_html_to_pdf($html, fn_get_lang_var('invoices') . '-' . implode('-', $_REQUEST['order_ids']));
     }
     exit;
 }
Beispiel #15
0
function fn_yandex_market_get_order_statuses_for_setting()
{
    static $data;
    if (empty($data)) {
        $data = array('' => ' -- ');
        foreach (fn_get_statuses(STATUSES_ORDER) as $status) {
            $data[$status['status']] = $status['description'];
        }
    }
    return $data;
}
Beispiel #16
0
function fn_send_return_mail(&$return_info, &$order_info, $force_notification = array())
{
    $return_statuses = fn_get_statuses(STATUSES_RETURN);
    $status_params = $return_statuses[$return_info['status']]['params'];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    $notify_vendor = isset($force_notification['V']) ? $force_notification['V'] : (!empty($status_params['notify_vendor']) && $status_params['notify_vendor'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true || $notify_vendor == true) {
        $rma_reasons = fn_get_rma_properties(RMA_REASON);
        $rma_actions = fn_get_rma_properties(RMA_ACTION);
        // Notify customer
        if ($notify_user == true) {
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $order_info['lang_code'])), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
        }
        if ($notify_vendor == true) {
            if (fn_allowed_for('MULTIVENDOR') && !empty($order_info['company_id'])) {
                $company_language = fn_get_company_language($order_info['company_id']);
                Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $company_language)), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'A', $company_language);
            }
        }
        // Notify administrator (only if the changes performed from the frontend)
        if ($notify_department == true) {
            Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => Registry::get('settings.Company.company_orders_department'), 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], Registry::get('settings.Appearance.backend_default_language'))), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language'));
        }
    }
}
Beispiel #17
0
                    Tygh::$app['view']->display('views/statuses/manage.tpl');
                }
            }
        }
        exit;
    }
    return array(CONTROLLER_STATUS_OK, 'statuses.manage?type=' . $_REQUEST['type']);
}
if ($mode == 'update') {
    $status_data = fn_get_status_data($_REQUEST['status'], $_REQUEST['type']);
    Tygh::$app['view']->assign('status_data', $status_data);
    Tygh::$app['view']->assign('type', $_REQUEST['type']);
    Tygh::$app['view']->assign('status_params', fn_get_status_params_definition($_REQUEST['type']));
} elseif ($mode == 'manage') {
    $section_data = array();
    $statuses = fn_get_statuses($_REQUEST['type'], array(), false, false, DESCR_SL);
    Tygh::$app['view']->assign('statuses', $statuses);
    $type = !empty($_REQUEST['type']) ? $_REQUEST['type'] : STATUSES_ORDER;
    Tygh::$app['view']->assign('type', $type);
    Tygh::$app['view']->assign('status_params', fn_get_status_params_definition($type));
    // Orders only
    if ($type == STATUSES_ORDER) {
        Tygh::$app['view']->assign('title', __('order_statuses'));
    }
}
function fn_get_status_params_definition($type)
{
    $status_params = array();
    if ($type == STATUSES_ORDER) {
        $status_params = array('color' => array('type' => 'color', 'label' => 'color'), 'notify' => array('type' => 'checkbox', 'label' => 'notify_customer', 'default_value' => 'Y'), 'notify_department' => array('type' => 'checkbox', 'label' => 'notify_orders_department'), 'notify_vendor' => array('type' => 'checkbox', 'label' => 'notify_vendor'), 'inventory' => array('type' => 'select', 'label' => 'inventory', 'variants' => array('I' => 'increase', 'D' => 'decrease')), 'remove_cc_info' => array('type' => 'checkbox', 'label' => 'remove_cc_info', 'default_value' => 'Y'), 'repay' => array('type' => 'checkbox', 'label' => 'pay_order_again'), 'appearance_type' => array('type' => 'select', 'label' => 'invoice_credit_memo', 'variants' => array('D' => 'default', 'I' => 'invoice', 'C' => 'credit_memo', 'O' => 'order')));
        if (fn_allowed_for('ULTIMATE:FREE')) {
 public static function importFileOrders($xml, $lang_code)
 {
     $cml = self::$cml;
     if (isset($xml->{$cml}['document'])) {
         $orders_data = $xml->{$cml}['document'];
         $statuses = array();
         $data_status = fn_get_statuses('O');
         if (!empty($data_status)) {
             foreach ($data_status as $status) {
                 $statuses[$status['description']] = array('status' => $status['status'], 'description' => $status['description']);
             }
         }
         foreach ($orders_data as $order_data) {
             $order_id = strval($order_data->{$cml}['id']);
             foreach ($order_data->{$cml}['value_fields']->{$cml}['value_field'] as $data_field) {
                 if (!empty($order_id) && $data_field->{$cml}['name'] == 'Статус заказа' && !empty($statuses[strval($data_field->{$cml}['value'])])) {
                     db_query("UPDATE ?:orders SET status = ?s WHERE order_id = ?i", $statuses[strval($data_field->{$cml}['value'])]['status'], $order_id);
                 }
             }
         }
     }
 }
Beispiel #19
0
    }
    $statistic_search_data['amount_from'] = empty($statistic_search_data['amount_from']) ? 0 : floatval($statistic_search_data['amount_from']);
    if (!empty($statistic_search_data['amount_from'])) {
        $statistic_conditions .= db_quote(" AND (amount >= ?d) ", fn_convert_price($statistic_search_data['amount_from']));
    }
    $statistic_search_data['amount_to'] = empty($statistic_search_data['amount_to']) ? 0 : floatval($statistic_search_data['amount_to']);
    if (!empty($statistic_search_data['amount_to'])) {
        $statistic_conditions .= db_quote(" AND (amount <= ?d) ", fn_convert_price($statistic_search_data['amount_to']));
    }
    $view->assign('statistic_search', $statistic_search_data);
    $general_stats = db_get_hash_array("SELECT action, COUNT(action) as count, SUM(amount) as sum, AVG(amount) as avg, COUNT(distinct partner_id) as partners FROM ?:aff_partner_actions as actions WHERE {$statistic_conditions} GROUP BY action", 'action');
    $general_stats['total'] = db_get_row("SELECT 'total' as action, COUNT(action) as count, SUM(amount) as sum, AVG(amount) as avg, COUNT(distinct partner_id) as partners FROM ?:aff_partner_actions as actions WHERE {$statistic_conditions}");
    $view->assign('general_stats', $general_stats);
    $additional_stats = array();
    $additional_stats['click_vs_show'] = empty($general_stats['show']['count']) ? '---' : (empty($general_stats['click']['count']) ? '0' : round($general_stats['click']['count'] / $general_stats['show']['count'] * 100, 1) . '% (' . intval($general_stats['click']['count']) . '/' . intval($general_stats['show']['count']) . ')');
    $additional_stats['sale_vs_click'] = empty($general_stats['click']['count']) ? '---' : (empty($general_stats['sale']['count']) ? '0' : round($general_stats['sale']['count'] / $general_stats['click']['count'] * 100, 1) . '% (' . intval($general_stats['sale']['count']) . '/' . intval($general_stats['click']['count']) . ')');
    $view->assign('additional_stats', $additional_stats);
    $list_plans = fn_get_affiliate_plans_list();
    $view->assign('list_plans', $list_plans);
    $view->assign('affiliate_plan', fn_get_affiliate_plan_data_by_partner_id($auth['user_id']));
    $sort_order = empty($_REQUEST['sort_order']) ? 'desc' : $_REQUEST['sort_order'];
    $sort_by = empty($_REQUEST['sort_by']) ? 'date' : $_REQUEST['sort_by'];
    $list_stats = fn_get_affiliate_actions($_SESSION['statistic_conditions'], array('sort_order' => $sort_order, 'sort_by' => $sort_by), true, @$_REQUEST['page']);
    $view->assign('sort_order', $sort_order == 'asc' ? 'desc' : 'asc');
    $view->assign('sort_by', $sort_by);
    if (!empty($list_stats)) {
        $view->assign('list_stats', $list_stats);
    }
    $order_status_descr = fn_get_statuses(STATUSES_ORDER, true, true, true);
    $view->assign('order_status_descr', $order_status_descr);
}
Beispiel #20
0
function fn_paypal_rma_update_details_post(&$data, &$show_confirmation_page, &$show_confirmation, &$is_refund, &$_data, &$confirmed)
{
    $change_return_status = $data['change_return_status'];
    if (($show_confirmation == false || $show_confirmation == true && $confirmed == 'Y') && $is_refund == 'Y') {
        $order_info = fn_get_order_info($change_return_status['order_id']);
        $amount = 0;
        $st_inv = fn_get_statuses(STATUSES_RETURN);
        if ($change_return_status['status_to'] != $change_return_status['status_from'] && $st_inv[$change_return_status['status_to']]['params']['inventory'] != 'D') {
            if (!empty($order_info['payment_method']) && !empty($order_info['payment_method']['processor_params']) && !empty($order_info['payment_info']) && !empty($order_info['payment_info']['transaction_id'])) {
                if (!empty($order_info['payment_method']['processor_params']['username']) && !empty($order_info['payment_method']['processor_params']['password'])) {
                    $request_data = array('METHOD' => 'RefundTransaction', 'VERSION' => '94', 'TRANSACTIONID' => $order_info['payment_info']['transaction_id']);
                    if (!empty($order_info['returned_products'])) {
                        foreach ($order_info['returned_products'] as $product) {
                            $amount += $product['subtotal'];
                        }
                    } elseif (!empty($order_info['products'])) {
                        foreach ($order_info['products'] as $product) {
                            if (isset($product['extra']['returns'])) {
                                foreach ($product['extra']['returns'] as $return_id => $return_data) {
                                    $amount += $return_data['amount'] * $product['subtotal'];
                                }
                            }
                        }
                    }
                    if ($amount != $order_info['subtotal'] || fn_allowed_for('MULTIVENDOR')) {
                        $request_data['REFUNDTYPE'] = 'Partial';
                        $request_data['AMT'] = $amount;
                        $request_data['CURRENCYCODE'] = isset($order_info['payment_method']['processor_params']['currency']) ? $order_info['payment_method']['processor_params']['currency'] : 'USD';
                        $request_data['NOTE'] = !empty($_REQUEST['comment']) ? $_REQUEST['comment'] : '';
                    } else {
                        $request_data['REFUNDTYPE'] = 'Full';
                    }
                    fn_paypal_build_request($order_info['payment_method'], $request_data, $post_url, $cert_file);
                    $result = fn_paypal_request($request_data, $post_url, $cert_file);
                }
            }
        }
    }
}
    function content_55ccdf859a2700_03616223($_smarty_tpl)
    {
        if (!is_callable('smarty_function_style')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.style.php';
        }
        $_smarty_tpl->_capture_stack[0][] = array("styles", null, null);
        ob_start();
        $_smarty_tpl->tpl_vars['type'] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['type']->value) === null || $tmp === '' ? @constant('STATUSES_ORDER') : $tmp, null, 0);
        $_smarty_tpl->tpl_vars['statuses'] = new Smarty_variable(fn_get_statuses($_smarty_tpl->tpl_vars['type']->value), null, 0);
        if ($_smarty_tpl->tpl_vars['statuses']->value) {
            ?>
	
    <?php 
            $_smarty_tpl->tpl_vars["status_data"] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars["status_data"]->_loop = false;
            $_smarty_tpl->tpl_vars["status"] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['statuses']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars["status_data"]->key => $_smarty_tpl->tpl_vars["status_data"]->value) {
                $_smarty_tpl->tpl_vars["status_data"]->_loop = true;
                $_smarty_tpl->tpl_vars["status"]->value = $_smarty_tpl->tpl_vars["status_data"]->key;
                ?>
        .<?php 
                echo htmlspecialchars(mb_strtolower($_smarty_tpl->tpl_vars['type']->value, 'UTF-8'), ENT_QUOTES, 'UTF-8');
                ?>
-status-<?php 
                echo htmlspecialchars(mb_strtolower($_smarty_tpl->tpl_vars['status']->value, 'UTF-8'), ENT_QUOTES, 'UTF-8');
                ?>
 {
            .buttonBackground(lighten(<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['status_data']->value['params']['color'], ENT_QUOTES, 'UTF-8');
                ?>
, 15%), darken(<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['status_data']->value['params']['color'], ENT_QUOTES, 'UTF-8');
                ?>
, 5%));
        }
    <?php 
            }
        }
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        echo smarty_function_style(array('content' => Smarty::$_smarty_vars['capture']['styles'], 'type' => "less"), $_smarty_tpl);
        ?>

<?php 
    }
Beispiel #22
0
    //
} elseif ($mode == 'details') {
    fn_add_breadcrumb(__('order_info'));
    $order_info = fn_get_order_info($_REQUEST['order_id']);
    if (empty($order_info)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    if ($order_info['is_parent_order'] == 'Y') {
        $child_ids = db_get_fields("SELECT order_id FROM ?:orders WHERE parent_order_id = ?i", $_REQUEST['order_id']);
        return array(CONTROLLER_STATUS_REDIRECT, 'orders.search?period=A&order_id=' . implode(',', $child_ids));
    }
    if (fn_allowed_for('MULTIVENDOR')) {
        Registry::get('view')->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($order_info['products']));
    }
    // Repay functionality
    $statuses = fn_get_statuses(STATUSES_ORDER, array(), true);
    if (Registry::get('settings.Checkout.repay') == 'Y' && (!empty($statuses[$order_info['status']]['params']['repay']) && $statuses[$order_info['status']]['params']['repay'] == 'Y')) {
        fn_prepare_repay_data(empty($_REQUEST['payment_id']) ? 0 : $_REQUEST['payment_id'], $order_info, $auth);
    }
    $navigation_tabs = array('general' => array('title' => __('general'), 'js' => true, 'href' => 'orders.details?order_id=' . $_REQUEST['order_id'] . '&selected_section=general'));
    list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true));
    $use_shipments = !fn_one_full_shipped($shipments);
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if (Registry::get('settings.General.use_shipments') == 'Y' || $use_shipments) {
            $navigation_tabs['shipment_info'] = array('title' => __('shipment_info'), 'js' => true, 'href' => 'orders.details?order_id=' . $_REQUEST['order_id'] . '&selected_section=shipment_info');
            $use_shipments = true;
        }
    }
    Registry::get('view')->assign('shipments', $shipments);
    Registry::get('view')->assign('use_shipments', $use_shipments);
    Registry::set('navigation.tabs', $navigation_tabs);
function fn_reports_get_conditions($conditions)
{
    $result = array();
    foreach ($conditions as $key => $value) {
        $result[$key]['objects'] = array();
        if ($key == "order") {
            foreach ($value as $v) {
                $result[$key]['objects'][] = array('href' => 'orders.details?order_id=' . $v, 'name' => '#' . $v);
            }
            $result[$key]['name'] = fn_get_lang_var('orders');
        } elseif ($key == "status") {
            $order_status_descr = fn_get_statuses(STATUSES_ORDER, true, true, true);
            foreach ($value as $k => $v) {
                $result[$key]['objects'][]['name'] = $order_status_descr[$v];
            }
            $result[$key]['name'] = fn_get_lang_var('status');
        } elseif ($key == "payment") {
            foreach ($value as $k => $v) {
                $result[$key]['objects'][]['name'] = db_get_field("SELECT payment FROM ?:payment_descriptions WHERE payment_id = ?i AND lang_code = ?s", $v, CART_LANGUAGE);
            }
            $result[$key]['name'] = fn_get_lang_var('payment_methods');
        } elseif ($key == "location") {
            foreach ($value as $k => $v) {
                $result[$key]['objects'][]['name'] = db_get_field("SELECT destination FROM ?:destination_descriptions WHERE destination_id = ?i AND lang_code = ?s", $v, CART_LANGUAGE);
            }
            $result[$key]['name'] = fn_get_lang_var('locations');
        } elseif ($key == "user") {
            foreach ($value as $v) {
                $result[$key]['objects'][] = array('href' => 'profiles.update?user_id=' . $v, 'name' => $v);
            }
            $result[$key]['name'] = fn_get_lang_var('users');
        } elseif ($key == "category") {
            foreach ($value as $k => $v) {
                $result[$key]['objects'][] = array('href' => 'categories.update?category_id=' . $v, 'name' => db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id = ?i AND lang_code = ?s", $v, CART_LANGUAGE));
            }
            $result[$key]['name'] = fn_get_lang_var('categories');
        } elseif ($key == "product") {
            foreach ($value as $v) {
                $result[$key]['objects'][] = array('href' => 'products.update&product_id=' . $v, 'name' => $v);
            }
            $result[$key]['name'] = fn_get_lang_var('products');
        }
    }
    return $result;
}
Beispiel #24
0
function fn_twg_get_statuses()
{
    $status_types = array('orders' => fn_get_statuses(STATUSES_ORDER), 'products' => fn_twg_api_get_base_statuses(true), 'categories' => fn_twg_api_get_base_statuses(true), 'users' => fn_twg_api_get_base_statuses(false));
    foreach ($status_types as &$status_type) {
        foreach ($status_type as &$status) {
            if (isset($status['color'])) {
                $color = $status['color'];
            } elseif (isset($status['params']['color'])) {
                $color = str_replace('#', '', $status['params']['color']);
            } else {
                $color = '666666';
            }
            $status = array('label' => $status['description'], 'value' => $status['status'], 'color' => $color);
        }
    }
    return $status_types;
}
Beispiel #25
0
     $orders_stat['taxes']['prev_subtotal'] = fn_get_orders_taxes_subtotal($orders_stat['prev_orders'], $search_params);
     $orders_stat['taxes']['diff'] = fn_calculate_differences($orders_stat['taxes']['subtotal'], $orders_stat['taxes']['prev_subtotal']);
 }
 if (!fn_check_view_permissions('orders.manage', 'GET')) {
     $orders_stat['orders'] = array();
     $orders_stat['prev_orders'] = array();
 }
 if (!fn_check_view_permissions('sales_reports.view', 'GET')) {
     $orders_stat['orders_total'] = array();
     $orders_stat['prev_orders_total'] = array();
 }
 /* /Orders */
 /* Order statuses */
 $order_statuses = array();
 if (fn_check_view_permissions('orders.manage', 'GET')) {
     $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), false, true);
 }
 /* /Order statuses */
 /* Recent activity block */
 $logs = array();
 if (fn_check_view_permissions('logs.manage', 'GET')) {
     list($logs, $search) = fn_get_logs(array('time_from' => $time_from, 'time_to' => $time_to, 'period' => 'C'), 10);
     // Get last 10 items
 }
 /* /Recent activity block */
 /* Order by statuses */
 $order_by_statuses = array();
 if (fn_check_view_permissions('orders.manage', 'GET')) {
     $company_condition = fn_get_company_condition('?:orders.company_id');
     $order_by_statuses = db_get_array("SELECT " . "?:status_descriptions.description as status_name, " . "?:orders.status, " . "COUNT(*) as count, " . "SUM(?:orders.total) as total, " . "SUM(?:orders.shipping_cost) as shipping " . "FROM ?:orders " . "INNER JOIN ?:status_descriptions " . "ON ?:status_descriptions.status = ?:orders.status " . "WHERE ?:status_descriptions.type = ?s " . "AND ?:orders.timestamp > ?i " . "AND ?:orders.timestamp < ?i " . "AND ?:status_descriptions.lang_code = ?s " . "?p " . "GROUP BY ?:orders.status ", 'O', $time_from, $time_to, CART_LANGUAGE, $company_condition);
 }
Beispiel #26
0
/**
 * Send order notification
 *
 * @param array $order_info order information
 * @param array $edp_data information about downloadable products
 * @param mixed $force_notification user notification flag (true/false), if not set, will be retrieved from status parameters
 * @return array structured data
 */
function fn_order_notification(&$order_info, $edp_data = array(), $force_notification = array())
{
    static $notified = array();
    $send_order_notification = true;
    if (!empty($notified[$order_info['order_id']][$order_info['status']]) && $notified[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) {
        $send_order_notification = false;
    }
    fn_set_hook('send_order_notification', $order_info, $edp_data, $force_notification, $notified, $send_order_notification);
    $take_surcharge_from_vendor = false;
    if (fn_allowed_for('MULTIVENDOR')) {
        $take_surcharge_from_vendor = fn_take_payment_surcharge_from_vendor($order_info['products']);
    }
    if (!$send_order_notification) {
        return true;
    }
    $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true, false, $order_info['lang_code'] ? $order_info['lang_code'] : CART_LANGUAGE, $order_info['company_id']);
    $status_params = $order_statuses[$order_info['status']]['params'];
    $notify_user = !empty($status_params['notify']) && $status_params['notify'] == 'Y';
    $notify_department = !empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y';
    $notify_vendor = !empty($status_params['notify_vendor']) && $status_params['notify_vendor'] == 'Y';
    if (!is_array($force_notification)) {
        $force_notification = fn_get_notification_rules($force_notification, !$force_notification);
    }
    if (isset($force_notification['C'])) {
        $notify_user = $force_notification['C'];
    }
    if (isset($force_notification['A'])) {
        $notify_department = $force_notification['A'];
    }
    if (isset($force_notification['V'])) {
        $notify_vendor = $force_notification['V'];
    }
    if ($notify_user || $notify_department || $notify_vendor) {
        $notified[$order_info['order_id']][$order_info['status']] = true;
        $order_status = $order_statuses[$order_info['status']];
        $payment_id = !empty($order_info['payment_method']['payment_id']) ? $order_info['payment_method']['payment_id'] : 0;
        $payment_method = fn_get_payment_data($payment_id, $order_info['order_id'], $order_info['lang_code']);
        $status_settings = $order_statuses[$order_info['status']]['params'];
        $profile_fields = fn_get_profile_fields('I', '', $order_info['lang_code']);
        $secondary_currency = '';
        list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true));
        $use_shipments = !fn_one_full_shipped($shipments);
        // restore secondary currency
        if (!empty($order_info['secondary_currency']) && Registry::get("currencies.{$order_info['secondary_currency']}")) {
            $secondary_currency = $order_info['secondary_currency'];
        }
        // Notify customer
        if ($notify_user == true) {
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'shipments' => $shipments, 'use_shipments' => $use_shipments, 'order_status' => $order_status, 'payment_method' => $payment_method, 'status_settings' => $status_settings, 'profile_fields' => $profile_fields, 'secondary_currency' => $secondary_currency, 'take_surcharge_from_vendor' => $take_surcharge_from_vendor), 'tpl' => 'orders/order_notification.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
            if (!empty($edp_data)) {
                Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'edp_data' => $edp_data), 'tpl' => 'orders/edp_access.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
            }
        }
        if ($notify_vendor == true) {
            if (fn_allowed_for('MULTIVENDOR') && !empty($order_info['company_id'])) {
                $company_lang_code = fn_get_company_language($order_info['company_id']);
                // Translate descriptions to admin language
                fn_translate_products($order_info['products'], '', $company_lang_code, true);
                Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => $order_info['email'], 'data' => array('order_info' => $order_info, 'shipments' => $shipments, 'use_shipments' => $use_shipments, 'order_status' => fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $company_lang_code), 'payment_method' => fn_get_payment_data($payment_id, $order_info['order_id'], $company_lang_code), 'status_settings' => $status_settings, 'profile_fields' => fn_get_profile_fields('I', '', $company_lang_code), 'secondary_currency' => $secondary_currency), 'tpl' => 'orders/order_notification.tpl', 'company_id' => $order_info['company_id']), 'A', $company_lang_code);
            }
        }
        // Notify order department
        if ($notify_department == true) {
            // Translate descriptions to admin language
            fn_translate_products($order_info['products'], '', Registry::get('settings.Appearance.backend_default_language'), true);
            $payment_method = array();
            if ($payment_id) {
                $payment_method = fn_get_payment_data($payment_id, $order_info['order_id'], Registry::get('settings.Appearance.backend_default_language'));
            }
            fn_add_user_data_descriptions($order_info, Registry::get('settings.Appearance.backend_default_language'));
            Mailer::sendMail(array('to' => 'default_company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => $order_info['email'], 'data' => array('order_info' => $order_info, 'shipments' => $shipments, 'use_shipments' => $use_shipments, 'order_status' => fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.backend_default_language')), 'payment_method' => $payment_method, 'status_settings' => $status_settings, 'profile_fields' => fn_get_profile_fields('I', '', Registry::get('settings.Appearance.backend_default_language')), 'secondary_currency' => $secondary_currency), 'tpl' => 'orders/order_notification.tpl', 'company_id' => $order_info['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language'));
        }
    }
    if (!empty($edp_data) && !$notify_user) {
        // Send out download links for EDP with "Immediately" Activation mode
        // TRUE if the EDP download links e-mail has already been sent. Used to avoid sending duplicate e-mails.
        $download_email_sent = false;
        foreach ($edp_data as $edp_item) {
            foreach ($edp_item['files'] as $file) {
                if (!empty($file['activation']) && $file['activation'] == 'I' && !$download_email_sent) {
                    Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'edp_data' => $edp_data), 'tpl' => 'orders/edp_access.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
                    $download_email_sent = true;
                    break;
                }
            }
        }
    }
    fn_set_hook('order_notification', $order_info, $order_statuses, $force_notification);
}
    function content_55d5c52c0f4b99_17469338($_smarty_tpl)
    {
        if (!is_callable('smarty_block_hook')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/block.hook.php';
        }
        if (!is_callable('smarty_modifier_date_format')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.date_format.php';
        }
        fn_preload_lang_vars(array('text_admin_new_orders', 'incompleted_orders', 'orders', 'id', 'status', 'date', 'customer', 'phone', 'total', 'order', 'invoice', 'credit_memo', 'view', 'edit', 'delete', 'no_data', 'for_this_page_orders', 'gross_total', 'totally_paid', 'for_all_found_orders', 'gross_total', 'totally_paid', 'add_order', 'bulk_print_invoice', 'bulk_print_pdf', 'bulk_print_packing_slip', 'view_purchased_products', 'export_selected', 'view_all_orders', 'incompleted_orders'));
        $_smarty_tpl->_capture_stack[0][] = array("mainbox", null, null);
        ob_start();
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['runtime']->value['mode'] == "new") {
            ?>
    <p><?php 
            echo $_smarty_tpl->__("text_admin_new_orders");
            ?>
</p>
<?php 
        }
        ?>

<?php 
        $_smarty_tpl->_capture_stack[0][] = array("sidebar", null, null);
        ob_start();
        ?>
    <?php 
        echo $_smarty_tpl->getSubTemplate("common/saved_search.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('dispatch' => "orders.manage", 'view_type' => "orders"), 0);
        ?>

    <?php 
        echo $_smarty_tpl->getSubTemplate("views/orders/components/orders_search_form.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('dispatch' => "orders.manage"), 0);
        ?>

<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<form action="<?php 
        echo htmlspecialchars(fn_url(''), ENT_QUOTES, 'UTF-8');
        ?>
" method="post" target="_self" name="orders_list_form">

<?php 
        echo $_smarty_tpl->getSubTemplate("common/pagination.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('save_current_page' => true, 'save_current_url' => true, 'div_id' => $_REQUEST['content_id']), 0);
        ?>


<?php 
        $_smarty_tpl->tpl_vars["c_url"] = new Smarty_variable(fn_query_remove($_smarty_tpl->tpl_vars['config']->value['current_url'], "sort_by", "sort_order"), null, 0);
        $_smarty_tpl->tpl_vars["c_icon"] = new Smarty_variable("<i class=\"exicon-" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev'] . "\"></i>", null, 0);
        $_smarty_tpl->tpl_vars["c_dummy"] = new Smarty_variable("<i class=\"exicon-dummy\"></i>", null, 0);
        ?>

<?php 
        $_smarty_tpl->tpl_vars["rev"] = new Smarty_variable(($tmp = @$_REQUEST['content_id']) === null || $tmp === '' ? "pagination_contents" : $tmp, null, 0);
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['incompleted_view']->value) {
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["page_title"] = new Smarty_variable($_smarty_tpl->__("incompleted_orders"), null, 0);
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["get_additional_statuses"] = new Smarty_variable(true, null, 0);
        } else {
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["page_title"] = new Smarty_variable($_smarty_tpl->__("orders"), null, 0);
            ?>
    <?php 
            $_smarty_tpl->tpl_vars["get_additional_statuses"] = new Smarty_variable(false, null, 0);
        }
        $_smarty_tpl->tpl_vars["order_status_descr"] = new Smarty_variable(fn_get_simple_statuses(@constant('STATUSES_ORDER'), $_smarty_tpl->tpl_vars['get_additional_statuses']->value, true), null, 0);
        $_smarty_tpl->tpl_vars["extra_status"] = new Smarty_variable(rawurlencode($_smarty_tpl->tpl_vars['config']->value['current_url']), null, 0);
        $_smarty_tpl->tpl_vars['statuses'] = new Smarty_variable(array(), null, 0);
        $_smarty_tpl->tpl_vars["order_statuses"] = new Smarty_variable(fn_get_statuses(@constant('STATUSES_ORDER'), $_smarty_tpl->tpl_vars['statuses']->value, $_smarty_tpl->tpl_vars['get_additional_statuses']->value, true), null, 0);
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['orders']->value) {
            ?>
<table width="100%" class="table table-middle">
<thead>
<tr>
    <th  class="left">
    <?php 
            echo $_smarty_tpl->getSubTemplate("common/check_items.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('check_statuses' => $_smarty_tpl->tpl_vars['order_status_descr']->value), 0);
            ?>

    </th>
    <th width="17%"><a class="cm-ajax" href="<?php 
            echo htmlspecialchars(fn_url((string) $_smarty_tpl->tpl_vars['c_url']->value . "&sort_by=order_id&sort_order=" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev']), ENT_QUOTES, 'UTF-8');
            ?>
" data-ca-target-id=<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['rev']->value, ENT_QUOTES, 'UTF-8');
            ?>
><?php 
            echo $_smarty_tpl->__("id");
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "order_id") {
                echo $_smarty_tpl->tpl_vars['c_icon']->value;
            } else {
                echo $_smarty_tpl->tpl_vars['c_dummy']->value;
            }
            ?>
</a></th>
    <th width="17%"><a class="cm-ajax" href="<?php 
            echo htmlspecialchars(fn_url((string) $_smarty_tpl->tpl_vars['c_url']->value . "&sort_by=status&sort_order=" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev']), ENT_QUOTES, 'UTF-8');
            ?>
" data-ca-target-id=<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['rev']->value, ENT_QUOTES, 'UTF-8');
            ?>
><?php 
            echo $_smarty_tpl->__("status");
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "status") {
                echo $_smarty_tpl->tpl_vars['c_icon']->value;
            } else {
                echo $_smarty_tpl->tpl_vars['c_dummy']->value;
            }
            ?>
</a></th>
    <th width="15%"><a class="cm-ajax" href="<?php 
            echo htmlspecialchars(fn_url((string) $_smarty_tpl->tpl_vars['c_url']->value . "&sort_by=date&sort_order=" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev']), ENT_QUOTES, 'UTF-8');
            ?>
" data-ca-target-id=<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['rev']->value, ENT_QUOTES, 'UTF-8');
            ?>
><?php 
            echo $_smarty_tpl->__("date");
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "date") {
                echo $_smarty_tpl->tpl_vars['c_icon']->value;
            } else {
                echo $_smarty_tpl->tpl_vars['c_dummy']->value;
            }
            ?>
</a></th>
    <th width="20%"><a class="cm-ajax" href="<?php 
            echo htmlspecialchars(fn_url((string) $_smarty_tpl->tpl_vars['c_url']->value . "&sort_by=customer&sort_order=" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev']), ENT_QUOTES, 'UTF-8');
            ?>
" data-ca-target-id=<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['rev']->value, ENT_QUOTES, 'UTF-8');
            ?>
><?php 
            echo $_smarty_tpl->__("customer");
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "customer") {
                echo $_smarty_tpl->tpl_vars['c_icon']->value;
            }
            ?>
</a></th>
    <th width="15%"><a class="cm-ajax" href="<?php 
            echo htmlspecialchars(fn_url((string) $_smarty_tpl->tpl_vars['c_url']->value . "&sort_by=phone&sort_order=" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev']), ENT_QUOTES, 'UTF-8');
            ?>
" data-ca-target-id=<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['rev']->value, ENT_QUOTES, 'UTF-8');
            ?>
><?php 
            echo $_smarty_tpl->__("phone");
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "phone") {
                echo $_smarty_tpl->tpl_vars['c_icon']->value;
            }
            ?>
</a></th>

    <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:manage_header"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "orders:manage_header"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "orders:manage_header"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>


    <th>&nbsp;</th>
    <th width="14%" class="right"><a class="cm-ajax<?php 
            if ($_smarty_tpl->tpl_vars['search']->value['sort_by'] == "total") {
                ?>
 sort-link-<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['search']->value['sort_order_rev'], ENT_QUOTES, 'UTF-8');
            }
            ?>
" href="<?php 
            echo htmlspecialchars(fn_url((string) $_smarty_tpl->tpl_vars['c_url']->value . "&sort_by=total&sort_order=" . (string) $_smarty_tpl->tpl_vars['search']->value['sort_order_rev']), ENT_QUOTES, 'UTF-8');
            ?>
" data-ca-target-id=<?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['rev']->value, ENT_QUOTES, 'UTF-8');
            ?>
><?php 
            echo $_smarty_tpl->__("total");
            ?>
</a></th>

</tr>
</thead>
<?php 
            $_smarty_tpl->tpl_vars["o"] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars["o"]->_loop = false;
            $_from = $_smarty_tpl->tpl_vars['orders']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars["o"]->key => $_smarty_tpl->tpl_vars["o"]->value) {
                $_smarty_tpl->tpl_vars["o"]->_loop = true;
                $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:order_row"));
                $_block_repeat = true;
                echo smarty_block_hook(array('name' => "orders:order_row"), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    ?>

<tr>
    <td class="left">
        <input type="checkbox" name="order_ids[]" value="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['order_id'], ENT_QUOTES, 'UTF-8');
                    ?>
" class="cm-item cm-item-status-<?php 
                    echo htmlspecialchars(mb_strtolower($_smarty_tpl->tpl_vars['o']->value['status'], 'UTF-8'), ENT_QUOTES, 'UTF-8');
                    ?>
" /></td>
    <td>
        <a href="<?php 
                    echo htmlspecialchars(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['o']->value['order_id']), ENT_QUOTES, 'UTF-8');
                    ?>
" class="underlined"><?php 
                    echo $_smarty_tpl->__("order");
                    ?>
 #<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['order_id'], ENT_QUOTES, 'UTF-8');
                    ?>
</a>
        <?php 
                    if ($_smarty_tpl->tpl_vars['order_statuses_data']->value[$_smarty_tpl->tpl_vars['o']->value['status']]['params']['appearance_type'] == "I" && $_smarty_tpl->tpl_vars['o']->value['invoice_id']) {
                        ?>
            <p class="small-note"><?php 
                        echo $_smarty_tpl->__("invoice");
                        ?>
 #<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['invoice_id'], ENT_QUOTES, 'UTF-8');
                        ?>
</p>
        <?php 
                    } elseif ($_smarty_tpl->tpl_vars['order_statuses_data']->value[$_smarty_tpl->tpl_vars['o']->value['status']]['params']['appearance_type'] == "C" && $_smarty_tpl->tpl_vars['o']->value['credit_memo_id']) {
                        ?>
            <p class="small-note"><?php 
                        echo $_smarty_tpl->__("credit_memo");
                        ?>
 #<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['credit_memo_id'], ENT_QUOTES, 'UTF-8');
                        ?>
</p>
        <?php 
                    }
                    ?>
        <?php 
                    echo $_smarty_tpl->getSubTemplate("views/companies/components/company_name.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('object' => $_smarty_tpl->tpl_vars['o']->value), 0);
                    ?>

    </td>
    <td>
        <?php 
                    if (fn_allowed_for("MULTIVENDOR")) {
                        ?>
            <?php 
                        $_smarty_tpl->tpl_vars["notify_vendor"] = new Smarty_variable(true, null, 0);
                        ?>
        <?php 
                    } else {
                        ?>
            <?php 
                        $_smarty_tpl->tpl_vars["notify_vendor"] = new Smarty_variable(false, null, 0);
                        ?>
        <?php 
                    }
                    ?>

        <?php 
                    echo $_smarty_tpl->getSubTemplate("common/select_popup.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('suffix' => "o", 'order_info' => $_smarty_tpl->tpl_vars['o']->value, 'id' => $_smarty_tpl->tpl_vars['o']->value['order_id'], 'status' => $_smarty_tpl->tpl_vars['o']->value['status'], 'items_status' => $_smarty_tpl->tpl_vars['order_status_descr']->value, 'update_controller' => "orders", 'notify' => true, 'notify_department' => true, 'notify_vendor' => $_smarty_tpl->tpl_vars['notify_vendor']->value, 'status_target_id' => "orders_total," . (string) $_smarty_tpl->tpl_vars['rev']->value, 'extra' => "&return_url=" . (string) $_smarty_tpl->tpl_vars['extra_status']->value, 'statuses' => $_smarty_tpl->tpl_vars['order_statuses']->value, 'btn_meta' => mb_strtolower("btn btn-info o-status-" . (string) $_smarty_tpl->tpl_vars['o']->value['status'] . " btn-small", 'UTF-8')), 0);
                    ?>

    </td>
    <td><?php 
                    echo htmlspecialchars(smarty_modifier_date_format($_smarty_tpl->tpl_vars['o']->value['timestamp'], (string) $_smarty_tpl->tpl_vars['settings']->value['Appearance']['date_format'] . ", " . (string) $_smarty_tpl->tpl_vars['settings']->value['Appearance']['time_format']), ENT_QUOTES, 'UTF-8');
                    ?>
</td>
    <td>
        <?php 
                    if ($_smarty_tpl->tpl_vars['o']->value['email']) {
                        ?>
<a href="mailto:<?php 
                        echo htmlspecialchars(rawurlencode($_smarty_tpl->tpl_vars['o']->value['email']), ENT_QUOTES, 'UTF-8');
                        ?>
">@</a> <?php 
                    }
                    ?>
        <?php 
                    if ($_smarty_tpl->tpl_vars['o']->value['user_id']) {
                        ?>
<a href="<?php 
                        echo htmlspecialchars(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['o']->value['user_id']), ENT_QUOTES, 'UTF-8');
                        ?>
"><?php 
                    }
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['lastname'], ENT_QUOTES, 'UTF-8');
                    ?>
 <?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['firstname'], ENT_QUOTES, 'UTF-8');
                    if ($_smarty_tpl->tpl_vars['o']->value['user_id']) {
                        ?>
</a><?php 
                    }
                    ?>
    </td>
    <td><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['o']->value['phone'], ENT_QUOTES, 'UTF-8');
                    ?>
</td>

    <?php 
                    $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:manage_data"));
                    $_block_repeat = true;
                    echo smarty_block_hook(array('name' => "orders:manage_data"), null, $_smarty_tpl, $_block_repeat);
                    while ($_block_repeat) {
                        ob_start();
                        $_block_content = ob_get_clean();
                        $_block_repeat = false;
                        echo smarty_block_hook(array('name' => "orders:manage_data"), $_block_content, $_smarty_tpl, $_block_repeat);
                    }
                    array_pop($_smarty_tpl->smarty->_tag_stack);
                    ?>


    <td width="5%" class="center">
        <?php 
                    $_smarty_tpl->_capture_stack[0][] = array("tools_items", null, null);
                    ob_start();
                    ?>
            <li><?php 
                    ob_start();
                    echo $_smarty_tpl->__("view");
                    $_tmp1 = ob_get_clean();
                    smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'href' => "orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['o']->value['order_id'], 'text' => $_tmp1));
                    ?>
</li>
            <?php 
                    $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:list_extra_links"));
                    $_block_repeat = true;
                    echo smarty_block_hook(array('name' => "orders:list_extra_links"), null, $_smarty_tpl, $_block_repeat);
                    while ($_block_repeat) {
                        ob_start();
                        ?>

                <li><?php 
                        ob_start();
                        echo $_smarty_tpl->__("edit");
                        $_tmp2 = ob_get_clean();
                        smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'href' => "order_management.edit?order_id=" . (string) $_smarty_tpl->tpl_vars['o']->value['order_id'], 'text' => $_tmp2));
                        ?>
</li>
                <?php 
                        $_smarty_tpl->tpl_vars["current_redirect_url"] = new Smarty_variable(rawurlencode($_smarty_tpl->tpl_vars['config']->value['current_url']), null, 0);
                        ?>
                <li><?php 
                        ob_start();
                        echo $_smarty_tpl->__("delete");
                        $_tmp3 = ob_get_clean();
                        smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'href' => "orders.delete?order_id=" . (string) $_smarty_tpl->tpl_vars['o']->value['order_id'] . "&redirect_url=" . (string) $_smarty_tpl->tpl_vars['current_redirect_url']->value, 'class' => "cm-confirm", 'text' => $_tmp3));
                        ?>
</li>
            <?php 
                        $_block_content = ob_get_clean();
                        $_block_repeat = false;
                        echo smarty_block_hook(array('name' => "orders:list_extra_links"), $_block_content, $_smarty_tpl, $_block_repeat);
                    }
                    array_pop($_smarty_tpl->smarty->_tag_stack);
                    ?>

        <?php 
                    list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
                    if (!empty($_capture_buffer)) {
                        if (isset($_capture_assign)) {
                            $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                        }
                        if (isset($_capture_append)) {
                            $_smarty_tpl->append($_capture_append, ob_get_contents());
                        }
                        Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
                    } else {
                        $_smarty_tpl->capture_error();
                    }
                    ?>
        <div class="hidden-tools">
            <?php 
                    smarty_template_function_dropdown($_smarty_tpl, array('content' => Smarty::$_smarty_vars['capture']['tools_items']));
                    ?>

        </div>
    </td>
    <td class="right">
        <?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['o']->value['total']), 0);
                    ?>

    </td>
</tr>
<?php 
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo smarty_block_hook(array('name' => "orders:order_row"), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
                ?>

<?php 
            }
            ?>
</table>
<?php 
        } else {
            ?>
    <p class="no-items"><?php 
            echo $_smarty_tpl->__("no_data");
            ?>
</p>
<?php 
        }
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['orders']->value) {
            ?>
    <div class="statistic clearfix" id="orders_total">
        <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:statistic_list"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "orders:statistic_list"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                ?>

        <table class="pull-right ">
            <?php 
                if ($_smarty_tpl->tpl_vars['total_pages']->value > 1 && $_smarty_tpl->tpl_vars['search']->value['page'] != "full_list") {
                    ?>
                <tr>
                    <td>&nbsp;</td>
                    <td width="100px"><?php 
                    echo $_smarty_tpl->__("for_this_page_orders");
                    ?>
:</td>
                </tr>
                <tr>
                    <td><?php 
                    echo $_smarty_tpl->__("gross_total");
                    ?>
:</td>
                    <td><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['display_totals']->value['gross_total']), 0);
                    ?>
</td>
                </tr>
                <?php 
                    if (!$_smarty_tpl->tpl_vars['incompleted_view']->value) {
                        ?>
                    <tr>
                        <td><?php 
                        echo $_smarty_tpl->__("totally_paid");
                        ?>
:</td>
                        <td><?php 
                        echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['display_totals']->value['totally_paid']), 0);
                        ?>
</td>
                    </tr>
                <?php 
                    }
                    ?>
                <hr />
                <tr>
                    <td><?php 
                    echo $_smarty_tpl->__("for_all_found_orders");
                    ?>
:</td>
                </tr>
            <?php 
                }
                ?>
            <tr>
                <td><?php 
                echo $_smarty_tpl->__("gross_total");
                ?>
:</td>
                <td><?php 
                echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['totals']->value['gross_total']), 0);
                ?>
</td>
            </tr>
            <?php 
                $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:totals_stats"));
                $_block_repeat = true;
                echo smarty_block_hook(array('name' => "orders:totals_stats"), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    ?>

                <?php 
                    if (!$_smarty_tpl->tpl_vars['incompleted_view']->value) {
                        ?>
                    <tr>
                        <td><h4><?php 
                        echo $_smarty_tpl->__("totally_paid");
                        ?>
:</h4></td>
                        <td class="price"><?php 
                        echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['totals']->value['totally_paid']), 0);
                        ?>
</td>
                    </tr>
                <?php 
                    }
                    ?>
            <?php 
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo smarty_block_hook(array('name' => "orders:totals_stats"), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
                ?>

        </table>
        <?php 
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "orders:statistic_list"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

    <!--orders_total--></div>
<?php 
        }
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate("common/pagination.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('div_id' => $_REQUEST['content_id']), 0);
        ?>



<?php 
        $_smarty_tpl->_capture_stack[0][] = array("adv_buttons", null, null);
        ob_start();
        ?>
    <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:manage_tools"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "orders:manage_tools"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

        <?php 
            echo $_smarty_tpl->getSubTemplate("common/tools.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('tool_href' => "order_management.new", 'prefix' => "bottom", 'hide_tools' => "true", 'title' => __("add_order"), 'icon' => "icon-plus"), 0);
            ?>

    <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "orders:manage_tools"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

</form>
<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        $_smarty_tpl->_capture_stack[0][] = array("buttons", null, null);
        ob_start();
        ?>
    <?php 
        $_smarty_tpl->_capture_stack[0][] = array("tools_list", null, null);
        ob_start();
        ?>
        <?php 
        if ($_smarty_tpl->tpl_vars['orders']->value) {
            ?>
            <li><?php 
            ob_start();
            echo $_smarty_tpl->__("bulk_print_invoice");
            $_tmp4 = ob_get_clean();
            smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => $_tmp4, 'dispatch' => "dispatch[orders.bulk_print]", 'form' => "orders_list_form", 'class' => "cm-new-window"));
            ?>
</li>
            <li><?php 
            ob_start();
            echo $_smarty_tpl->__("bulk_print_pdf");
            $_tmp5 = ob_get_clean();
            smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => $_tmp5, 'dispatch' => "dispatch[orders.bulk_print..pdf]", 'form' => "orders_list_form"));
            ?>
</li>            
            <li><?php 
            ob_start();
            echo $_smarty_tpl->__("bulk_print_packing_slip");
            $_tmp6 = ob_get_clean();
            smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => $_tmp6, 'dispatch' => "dispatch[orders.packing_slip]", 'form' => "orders_list_form", 'class' => "cm-new-window"));
            ?>
</li>
            <li><?php 
            ob_start();
            echo $_smarty_tpl->__("view_purchased_products");
            $_tmp7 = ob_get_clean();
            smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => $_tmp7, 'dispatch' => "dispatch[orders.products_range]", 'form' => "orders_list_form"));
            ?>
</li>
            
            <li class="divider"></li>
            <li><?php 
            ob_start();
            echo $_smarty_tpl->__("export_selected");
            $_tmp8 = ob_get_clean();
            smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => $_tmp8, 'dispatch' => "dispatch[orders.export_range]", 'form' => "orders_list_form"));
            ?>
</li>
            <?php 
            if ($_smarty_tpl->tpl_vars['incompleted_view']->value) {
                ?>
                <li><?php 
                ob_start();
                echo $_smarty_tpl->__("view_all_orders");
                $_tmp9 = ob_get_clean();
                smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'href' => "orders.manage", 'text' => $_tmp9));
                ?>
</li>
            <?php 
            } else {
                ?>
                <li><?php 
                ob_start();
                echo $_smarty_tpl->__("incompleted_orders");
                $_tmp10 = ob_get_clean();
                smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'href' => "orders.manage?skip_view=Y&status=" . (string) @constant('STATUS_INCOMPLETED_ORDER'), 'text' => $_tmp10, 'form' => "orders_list_form"));
                ?>
</li>
            <?php 
            }
            ?>
            <?php 
            if ($_smarty_tpl->tpl_vars['orders']->value && !$_smarty_tpl->tpl_vars['runtime']->value['company_id']) {
                ?>
                <li class="divider"></li>
                <li><?php 
                smarty_template_function_btn($_smarty_tpl, array('type' => "delete_selected", 'dispatch' => "dispatch[orders.m_delete]", 'form' => "orders_list_form"));
                ?>
</li>
            <?php 
            }
            ?>
        <?php 
        }
        ?>
        <?php 
        $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "orders:list_tools"));
        $_block_repeat = true;
        echo smarty_block_hook(array('name' => "orders:list_tools"), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>

        <?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_hook(array('name' => "orders:list_tools"), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>

    <?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>
    <?php 
        smarty_template_function_dropdown($_smarty_tpl, array('content' => Smarty::$_smarty_vars['capture']['tools_list']));
        ?>

<?php 
        list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
        if (!empty($_capture_buffer)) {
            if (isset($_capture_assign)) {
                $_smarty_tpl->assign($_capture_assign, ob_get_contents());
            }
            if (isset($_capture_append)) {
                $_smarty_tpl->append($_capture_append, ob_get_contents());
            }
            Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
        } else {
            $_smarty_tpl->capture_error();
        }
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate("common/mainbox.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('title' => $_smarty_tpl->tpl_vars['page_title']->value, 'sidebar' => Smarty::$_smarty_vars['capture']['sidebar'], 'content' => Smarty::$_smarty_vars['capture']['mainbox'], 'buttons' => Smarty::$_smarty_vars['capture']['buttons'], 'adv_buttons' => Smarty::$_smarty_vars['capture']['adv_buttons'], 'content_id' => "manage_orders"), 0);
        ?>

<?php 
    }
Beispiel #28
0
/**
 * Get promotion dynamic properties
 *
 * @param array $promotion_id promotion ID
 * @param array $promotion promotion condition
 * @param array $condition condition
 * @param array $cart cart
 * @param array $auth auth information
 * @return mixed
 */
function fn_promotion_get_dynamic($promotion_id, $promotion, $condition, &$cart, &$auth = NULL)
{
    if ($condition == 'number_of_usages') {
        $usages = db_get_field("SELECT number_of_usages FROM ?:promotions WHERE promotion_id = ?i", $promotion_id);
        return intval($usages) + 1;
    } elseif ($condition == 'once_per_customer') {
        fn_define('PROMOTION_MIN_MATCHES', 5);
        $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true);
        $_statuses = array();
        foreach ($order_statuses as $v) {
            if ($v['inventory'] == 'D') {
                // decreasing (positive) status
                $_statuses[] = $v['status'];
            }
        }
        if (empty($cart['user_data'])) {
            return 'Y';
        }
        $udata = $cart['user_data'];
        fn_fill_user_fields($udata);
        $exists = db_get_field("SELECT ((firstname = ?s) + (lastname = ?s) + (b_city = ?s) + (b_state = ?s) + (b_country = ?s) + (b_zipcode = ?s) + (email = ?s) * 6) as r FROM ?:orders WHERE FIND_IN_SET(promotion_ids, ?i) AND status IN (?a) HAVING r >= ?i LIMIT 1", $udata['firstname'], $udata['lastname'], $udata['b_city'], $udata['b_state'], $udata['b_country'], $udata['b_zipcode'], $udata['email'], $promotion_id, $_statuses, PROMOTION_MIN_MATCHES);
        $promotion_data = fn_get_promotion_data($promotion_id);
        $coupon_exist = false;
        if (!empty($promotion_data['conditions']['conditions'])) {
            foreach ($promotion_data['conditions']['conditions'] as $val) {
                if ($val['condition'] == 'coupon_code') {
                    $coupon_exist = fn_promotion_validate_coupon($val, $cart);
                    if (!empty($coupon_exist) && !empty($exists)) {
                        fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('text_can_be_used_once'), false, 'error_coupon_already_used');
                    }
                    break;
                }
            }
        }
        if (!empty($exists)) {
            return 'N';
        }
        return 'Y';
        // this is checkbox with values (Y/N), so we need to return appropriate values
    }
}
Beispiel #29
0
function fn_rma_update_details($data)
{
    fn_set_hook('rma_update_details_pre', $data);
    $change_return_status = $data['change_return_status'];
    $_data = array();
    $show_confirmation_page = false;
    if (isset($data['comment'])) {
        $_data['comment'] = $data['comment'];
    }
    $is_refund = fn_is_refund_action($change_return_status['action']);
    $confirmed = isset($data['confirmed']) ? $data['confirmed'] : '';
    $st_inv = fn_get_statuses(STATUSES_RETURN);
    $show_confirmation = false;
    if (($change_return_status['recalculate_order'] == 'M' && $is_refund == 'Y' || $change_return_status['recalculate_order'] == 'R') && $change_return_status['status_to'] != $change_return_status['status_from'] && !($st_inv[$change_return_status['status_from']]['params']['inventory'] == 'D' && $change_return_status['status_to'] == RMA_DEFAULT_STATUS) && !($st_inv[$change_return_status['status_to']]['params']['inventory'] == 'D' && $change_return_status['status_from'] == RMA_DEFAULT_STATUS)) {
        $show_confirmation = true;
    }
    if ($show_confirmation == true) {
        if ($confirmed == 'Y') {
            fn_rma_recalculate_order($change_return_status['order_id'], $change_return_status['recalculate_order'], $change_return_status['return_id'], $is_refund, $change_return_status);
            $_data['status'] = $change_return_status['status_to'];
        } else {
            $change_return_status['inventory_to'] = $st_inv[$change_return_status['status_to']]['params']['inventory'];
            $change_return_status['inventory_from'] = $st_inv[$change_return_status['status_from']]['params']['inventory'];
            $_SESSION['change_return_status'] = $change_return_status;
            $show_confirmation_page = true;
        }
    } else {
        $_data['status'] = $change_return_status['status_to'];
    }
    if (!empty($_data)) {
        db_query("UPDATE ?:rma_returns SET ?u WHERE return_id = ?i", $_data, $change_return_status['return_id']);
    }
    if (($show_confirmation == false || $show_confirmation == true && $confirmed == 'Y') && $change_return_status['status_from'] != $change_return_status['status_to']) {
        $order_items = db_get_hash_single_array("SELECT item_id, extra FROM ?:order_details WHERE ?:order_details.order_id = ?i", array('item_id', 'extra'), $change_return_status['order_id']);
        foreach ($order_items as $item_id => $extra) {
            $extra = @unserialize($extra);
            if (isset($extra['returns'][$change_return_status['return_id']])) {
                $extra['returns'][$change_return_status['return_id']]['status'] = $change_return_status['status_to'];
                db_query('UPDATE ?:order_details SET ?u WHERE item_id = ?i AND order_id = ?i', array('extra' => serialize($extra)), $item_id, $change_return_status['order_id']);
            }
        }
        $return_info = fn_get_return_info($change_return_status['return_id']);
        $order_info = fn_get_order_info($change_return_status['order_id']);
        fn_send_return_mail($return_info, $order_info, fn_get_notification_rules($change_return_status));
    }
    fn_set_hook('rma_update_details_post', $data, $show_confirmation_page, $show_confirmation, $is_refund, $_data, $confirmed);
    return $show_confirmation_page;
}
Beispiel #30
0
function fn_send_return_mail(&$return_info, &$order_info, $force_notification = array())
{
    $return_statuses = fn_get_statuses(STATUSES_RETURN);
    $status_params = $return_statuses[$return_info['status']];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true) {
        Registry::get('view_mail')->assign('order_info', $order_info);
        Registry::get('view_mail')->assign('return_info', $return_info);
        Registry::get('view_mail')->assign('reasons', fn_get_rma_properties(RMA_REASON));
        Registry::get('view_mail')->assign('actions', fn_get_rma_properties(RMA_ACTION));
        Registry::get('view_mail')->assign('return_status', fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $order_info['lang_code']));
        // Notify customer
        if ($notify_user == true) {
            fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'addons/rma/slip_notification_subj.tpl', 'addons/rma/slip_notification.tpl', '', $order_info['lang_code']);
        }
        // Notify administrator (only if the changes performed from customer area)
        if (AREA == 'C' || $notify_department == true) {
            // Translate descriptions to admin language
            Registry::get('view_mail')->assign('return_status', fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], Registry::get('settings.Appearance.admin_default_language')));
            fn_send_mail(Registry::get('settings.Company.company_orders_department'), Registry::get('settings.Company.company_orders_department'), 'addons/rma/slip_notification_subj.tpl', 'addons/rma/slip_notification.tpl', '', Registry::get('settings.Appearance.admin_default_language'), $order_info['email']);
        }
    }
}