コード例 #1
0
 public function connectAdmin($user_data, $is_reconnect = false)
 {
     if (!$this->_initHisPublicKey()) {
         return false;
     }
     $store_info = self::getAdminUrls();
     if (!$is_reconnect && !self::_needToConnect($store_info)) {
         return false;
     }
     $meta = array();
     // Connect admin panel
     $data = array('public_key' => $this->getMyPublicKey(), 'addon_version' => TWIGMO_VERSION, 'engine' => 'cscart', 'engine_version' => PRODUCT_VERSION, 'engine_meta' => PRODUCT_EDITION, 'saas_uid' => fn_twg_get_saas_uid(), 'name' => Registry::get('settings.Company.company_name'));
     if ($store_info['access_id']) {
         $meta['access_id'] = $store_info['access_id'];
     } else {
         $data = array_merge($data, fn_get_user_info($user_data['user_id']));
         $data = array_merge($data, array('email' => $user_data['email'], 'password' => $user_data['password']));
     }
     $data = array_merge($data, $store_info);
     self::_setConnectTTL();
     $response = $this->send('connect.admin', $data, $meta);
     if (!$this->responseIsOk($response) or empty($response['data']['access_id'])) {
         self::_setConnectionErrorNotification();
         return false;
     }
     $new_options = array('version' => TWIGMO_VERSION, 'admin_connection' => array('access_id' => $response['data']['access_id'], 'url' => $data['url']));
     if (!empty($user_data['email'])) {
         $new_options['email'] = $user_data['email'];
     }
     if ($store_info['access_id'] && $response['data']['access_id'] != $store_info['access_id']) {
         // access_id changed - we have to disconnect storefronts
         $customer_connections = TwigmoSettings::get('customer_connections');
         if (is_array($customer_connections)) {
             foreach ($customer_connections as $company_id => $customer_connection) {
                 $customer_connections[$company_id]['access_id'] = '';
             }
             $new_options['customer_connections'] = $customer_connections;
         }
     }
     TwigmoSettings::set($new_options);
     return true;
 }
    function content_55ccf7c33c4939_75303952($_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_unpuny')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.unpuny.php';
        }
        fn_preload_lang_vars(array('previous_period', 'current_period', 'orders', 'sales', 'taxes', 'users_carts', 'order', 'by', 'no_data', 'recent_orders', 'statistics', 'active_products', 'out_of_stock_products', 'registered_customers', 'categories', 'vendors', 'web_pages', 'order_by_status', 'status', 'qty', 'shipping', 'recent_activity', 'order', 'dashboard', 'installer_complete_title', 'welcome_screen.administrator_info', 'admin_panel', 'welcome_screen.go_admin_panel', 'welcome_screen.go_settings_wizard', 'settings_wizard', 'welcome_screen.run_settings_wizard', 'storefront', 'welcome_screen.go_storefront', 'welcome_screen.learn_more_configuration', 'welcome_screen.knowledge_base', 'welcome_screen.thanks'));
        $_smarty_tpl->_capture_stack[0][] = array("mainbox", null, null);
        ob_start();
        $_smarty_tpl->tpl_vars["show_latest_orders"] = new Smarty_variable(fn_check_permissions("orders", 'manage', 'admin'), null, 0);
        $_smarty_tpl->tpl_vars["show_orders"] = new Smarty_variable(fn_check_permissions("sales_reports", 'reports', 'admin'), null, 0);
        $_smarty_tpl->tpl_vars["show_inventory"] = new Smarty_variable(fn_check_permissions("products", 'manage', 'admin'), null, 0);
        $_smarty_tpl->tpl_vars["show_users"] = new Smarty_variable(fn_check_permissions("profiles", 'manage', 'admin'), null, 0);
        ?>

<?php 
        $_smarty_tpl->tpl_vars["user_can_view_orders"] = new Smarty_variable(fn_check_view_permissions("orders.manage", 'GET'), null, 0);
        ?>

<script type="text/javascript">
(function(_, $) {

    _.drawChart = function(is_day) {
        if (typeof google == "undefined") {
            return false;
        }

        function get_data(div) {
            var id = $(div).attr('id');
            var dataTable = new google.visualization.DataTable();
            if (is_day) {
                dataTable.addColumn('timeofday', 'Date');
            } else {
                dataTable.addColumn('date', 'Date');
            }
            dataTable.addColumn('number', '<?php 
        echo $_smarty_tpl->__("previous_period");
        ?>
');
            dataTable.addColumn('number', '<?php 
        echo $_smarty_tpl->__("current_period");
        ?>
');
            dataTable.addRows(_.chart_data[id]);

            var dataView = new google.visualization.DataView(dataTable);
            dataView.setColumns([0, 1, 2]);

            return dataView;
        }

        var options = {
            chartArea: {
                left: 7,
                top: 10,
                width: 556,
                height: 208
            },
            colors: ['#f491a5','#8fd1ff'],
            tooltip: {
                showColorCode: true
            },
            lineWidth: 4,
            hAxis: {
                baselineColor: '#e1e1e1',
                textStyle: {
                    color: '#a1a1a1',
                    fontSize: 11
                },
                gridlines: {
                    count: 6
                }
            },
            legend: {
                position: 'none'
            },
            pointSize: 10,
            vAxis: {
                minValue: 0,
                baselineColor: '#e1e1e1',
                textPosition: 'in',
                textStyle: {
                    color: '#a1a1a1',
                    fontSize: 11
                },
                gridlines: {
                    count: 10
                }
            }
        };
        if (!is_day) {
            options.hAxis.format = 'MMM d';
        }

        $('.dashboard-statistics-chart:visible').each(function(i, div) {
            var dataView = get_data(div);
            var chart = new google.visualization.AreaChart(div);
            chart.draw(dataView, options);
        });

        $('#statistics_tabs .tabs li').on('click', function() {
            $('.dashboard-statistics-chart:visible').each(function(i, div) {
                var dataView = get_data(div);
                var chart = new google.visualization.AreaChart(div);
                chart.draw(dataView, options);
            });
        });
    }

    $(document).ready(function() {
        $.getScript('//www.google.com/jsapi', function() {
            setTimeout(function() { // do not remove it - otherwise it will be slow in ff
                google.load('visualization', '1.0', {
                    packages: ['corechart'],
                    callback: function() {
                        _.drawChart(<?php 
        echo htmlspecialchars($_smarty_tpl->tpl_vars['is_day']->value, ENT_QUOTES, 'UTF-8');
        ?>
);
                    }
                });
            }, 0);
        });

    });
}(Tygh, Tygh.$));
</script>

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

<div class="dashboard" id="dashboard">
    <table class="dashboard-card-table">
        <tbody>
            <tr>
                <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:finance_statistic"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "index:finance_statistic"), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                ?>

                <?php 
                if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['orders'])) {
                    ?>
                    <td>
                        <div class="dashboard-card">
                            <div class="dashboard-card-title"><?php 
                    echo $_smarty_tpl->__("orders");
                    ?>
</div>
                            <div class="dashboard-card-content">
                                <h3>
                                    <?php 
                    if ($_smarty_tpl->tpl_vars['user_can_view_orders']->value) {
                        ?>
                                        <a href="<?php 
                        echo htmlspecialchars(fn_url("orders.manage?is_search=Y&period=C&time_from=" . (string) $_smarty_tpl->tpl_vars['time_from']->value . "&time_to=" . (string) $_smarty_tpl->tpl_vars['time_to']->value), ENT_QUOTES, 'UTF-8');
                        ?>
"><?php 
                        echo htmlspecialchars(count($_smarty_tpl->tpl_vars['orders_stat']->value['orders']), ENT_QUOTES, 'UTF-8');
                        ?>
</a>
                                    <?php 
                    } else {
                        ?>
                                        <?php 
                        echo htmlspecialchars(count($_smarty_tpl->tpl_vars['orders_stat']->value['orders']), ENT_QUOTES, 'UTF-8');
                        ?>

                                    <?php 
                    }
                    ?>
                                </h3>
                                <?php 
                    echo htmlspecialchars(count($_smarty_tpl->tpl_vars['orders_stat']->value['prev_orders']), ENT_QUOTES, 'UTF-8');
                    ?>
, <?php 
                    if ($_smarty_tpl->tpl_vars['orders_stat']->value['diff']['orders_count'] > 0) {
                        ?>
+<?php 
                    }
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['orders_stat']->value['diff']['orders_count'], ENT_QUOTES, 'UTF-8');
                    ?>

                            </div>
                        </div>
                    </td>
                <?php 
                }
                ?>
                <?php 
                if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['orders_total'])) {
                    ?>
                    <td>
                        <div class="dashboard-card">
                            <div class="dashboard-card-title"><?php 
                    echo $_smarty_tpl->__("sales");
                    ?>
</div>
                            <div class="dashboard-card-content">
                                <h3><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['orders_total']['totally_paid']), 0);
                    ?>
</h3><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['prev_orders_total']['totally_paid']), 0);
                    ?>
, <?php 
                    if ($_smarty_tpl->tpl_vars['orders_stat']->value['orders_total']['totally_paid'] > $_smarty_tpl->tpl_vars['orders_stat']->value['prev_orders_total']['totally_paid']) {
                        ?>
+<?php 
                    }
                    echo $_smarty_tpl->tpl_vars['orders_stat']->value['diff']['sales'];
                    ?>
%
                            </div>
                        </div>
                    </td>
                <?php 
                }
                ?>
                <?php 
                if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['taxes'])) {
                    ?>
                    <td>
                        <div class="dashboard-card">
                            <div class="dashboard-card-title"><?php 
                    echo $_smarty_tpl->__("taxes");
                    ?>
</div>
                            <div class="dashboard-card-content">
                                <h3><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['subtotal']), 0);
                    ?>
</h3><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['prev_subtotal']), 0);
                    ?>
, <?php 
                    if ($_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['subtotal'] > $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['prev_subtotal']) {
                        ?>
+<?php 
                    }
                    echo $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['diff'];
                    ?>
%
                            </div>
                        </div>
                    </td>
                <?php 
                }
                ?>
                <?php 
                if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['abandoned_cart_total'])) {
                    ?>
                    <td>
                        <div class="dashboard-card">
                            <div class="dashboard-card-title"><?php 
                    echo $_smarty_tpl->__("users_carts");
                    ?>
</div>
                            <div class="dashboard-card-content">
                                <h3><?php 
                    echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['orders_stat']->value['abandoned_cart_total']) === null || $tmp === '' ? 0 : $tmp, ENT_QUOTES, 'UTF-8');
                    ?>
</h3><?php 
                    echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['orders_stat']->value['prev_abandoned_cart_total']) === null || $tmp === '' ? 0 : $tmp, ENT_QUOTES, 'UTF-8');
                    ?>
, <?php 
                    if ($_smarty_tpl->tpl_vars['orders_stat']->value['abandoned_cart_total'] > $_smarty_tpl->tpl_vars['orders_stat']->value['prev_abandoned_cart_total']) {
                        ?>
+<?php 
                    }
                    echo $_smarty_tpl->tpl_vars['orders_stat']->value['diff']['abandoned_carts'];
                    ?>
%
                            </div>
                        </div>
                    </td>
                <?php 
                }
                ?>
                <?php 
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo smarty_block_hook(array('name' => "index:finance_statistic"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

            </tr>
        </tbody>
    </table>

    <?php 
            if (!is_callable('smarty_modifier_date_format')) {
                include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.date_format.php';
            }
            if (!function_exists('smarty_template_function_get_orders')) {
                function smarty_template_function_get_orders($_smarty_tpl, $params)
                {
                    $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                    foreach ($_smarty_tpl->smarty->template_functions['get_orders']['parameter'] as $key => $value) {
                        $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                    }
                    foreach ($params as $key => $value) {
                        $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                    }
                    ?>
        <?php 
                    $_smarty_tpl->tpl_vars['params'] = new Smarty_variable(array('status' => $_smarty_tpl->tpl_vars['status']->value, 'time_from' => $_smarty_tpl->tpl_vars['time_from']->value, 'time_to' => $_smarty_tpl->tpl_vars['time_to']->value, 'period' => 'C'), null, 0);
                    ?>
        <?php 
                    $_smarty_tpl->tpl_vars['orders'] = new Smarty_variable(fn_get_orders($_smarty_tpl->tpl_vars['params']->value, $_smarty_tpl->tpl_vars['limit']->value), null, 0);
                    ?>

        <table class="table table-middle table-last-td-align-right">
            <tbody>
            <?php 
                    $_smarty_tpl->tpl_vars["order"] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars["order"]->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['orders']->value[0];
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars["order"]->key => $_smarty_tpl->tpl_vars["order"]->value) {
                        $_smarty_tpl->tpl_vars["order"]->_loop = true;
                        ?>
                <tr>
                    <td>
                        <span class="label btn-info o-status-<?php 
                        echo htmlspecialchars(mb_strtolower($_smarty_tpl->tpl_vars['order']->value['status'], 'UTF-8'), ENT_QUOTES, 'UTF-8');
                        ?>
"><?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['order_statuses']->value[$_smarty_tpl->tpl_vars['order']->value['status']]['description'], ENT_QUOTES, 'UTF-8');
                        ?>
</span>
                    </td>
                    <td><a href="<?php 
                        echo htmlspecialchars(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['order']->value['order_id']), ENT_QUOTES, 'UTF-8');
                        ?>
"><?php 
                        echo $_smarty_tpl->__("order");
                        ?>
 #<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['order']->value['order_id'], ENT_QUOTES, 'UTF-8');
                        ?>
</a> <?php 
                        echo $_smarty_tpl->__("by");
                        ?>
 <?php 
                        if ($_smarty_tpl->tpl_vars['order']->value['user_id']) {
                            ?>
<a href="<?php 
                            echo htmlspecialchars(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['order']->value['user_id']), ENT_QUOTES, 'UTF-8');
                            ?>
"><?php 
                        }
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['order']->value['lastname'], ENT_QUOTES, 'UTF-8');
                        ?>
 <?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['order']->value['firstname'], ENT_QUOTES, 'UTF-8');
                        if ($_smarty_tpl->tpl_vars['order']->value['user_id']) {
                            ?>
</a><?php 
                        }
                        ?>
</td>
                    <td><span class="date"><?php 
                        echo htmlspecialchars(smarty_modifier_date_format($_smarty_tpl->tpl_vars['order']->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');
                        ?>
</span></td>
                    <td><h4><?php 
                        echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['order']->value['total']), 0);
                        ?>
</h4></td>
                </tr>
            <?php 
                    }
                    if (!$_smarty_tpl->tpl_vars["order"]->_loop) {
                        ?>
                <tr><td><?php 
                        echo $_smarty_tpl->__("no_data");
                        ?>
</td></tr>
            <?php 
                    }
                    ?>
            </tbody>
        </table>
    <?php 
                    $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                    foreach (Smarty::$global_tpl_vars as $key => $value) {
                        if (!isset($_smarty_tpl->tpl_vars[$key])) {
                            $_smarty_tpl->tpl_vars[$key] = $value;
                        }
                    }
                }
            }
            ?>


    <div class="dashboard-row">
        <?php 
            if (!empty($_smarty_tpl->tpl_vars['order_statuses']->value)) {
                ?>
            <div class="dashboard-recent-orders cm-j-tabs tabs" data-ca-width="500">
                <h4><?php 
                echo $_smarty_tpl->__("recent_orders");
                ?>
</h4>
                <ul class="nav nav-pills">
                    <li id="tab_recent_all" class="active cm-js"><a href="#status_all" data-toggle="tab">All</a></li>
                    <?php 
                $_smarty_tpl->tpl_vars["status"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["status"]->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['order_statuses']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["status"]->key => $_smarty_tpl->tpl_vars["status"]->value) {
                    $_smarty_tpl->tpl_vars["status"]->_loop = true;
                    ?>
                        <li id="tab_recent_<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['status'], ENT_QUOTES, 'UTF-8');
                    ?>
" class="cm-js"><a href="#status_<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['status'], ENT_QUOTES, 'UTF-8');
                    ?>
" data-toggle="tab"><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['description'], ENT_QUOTES, 'UTF-8');
                    ?>
</a></li>
                    <?php 
                }
                ?>
                </ul>

                <div class="tab-content cm-tabs-content">
                    <div class="tab-pane" id="content_tab_recent_all">
                        <?php 
                smarty_template_function_get_orders($_smarty_tpl, array('status' => ''));
                ?>

                    </div>
                    <?php 
                $_smarty_tpl->tpl_vars["status"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["status"]->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['order_statuses']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["status"]->key => $_smarty_tpl->tpl_vars["status"]->value) {
                    $_smarty_tpl->tpl_vars["status"]->_loop = true;
                    ?>
                        <div class="tab-pane" id="content_tab_recent_<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['status'], ENT_QUOTES, 'UTF-8');
                    ?>
">
                            <?php 
                    smarty_template_function_get_orders($_smarty_tpl, array('status' => $_smarty_tpl->tpl_vars['status']->value['status']));
                    ?>

                        </div>
                    <?php 
                }
                ?>
                </div>
            </div>
        <?php 
            }
            ?>
        <?php 
            if (!empty($_smarty_tpl->tpl_vars['graphs']->value)) {
                ?>
            <div class="dashboard-statistics">
                <h4>
                    <?php 
                echo $_smarty_tpl->__("statistics");
                ?>

                </h4>
                 <?php 
                $_smarty_tpl->_capture_stack[0][] = array("chart_tabs", null, null);
                ob_start();
                ?>
                <div id="content_sales_chart">
                    <div id="dashboard_statistics_sales_chart" class="dashboard-statistics-chart spinner">
                    </div>
                </div>
                <?php 
                $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:chart_statistic"));
                $_block_repeat = true;
                echo smarty_block_hook(array('name' => "index:chart_statistic"), 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' => "index:chart_statistic"), $_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 id="statistics_tabs">
                    <?php 
                echo $_smarty_tpl->getSubTemplate("common/tabsbox.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('content' => Smarty::$_smarty_vars['capture']['chart_tabs']), 0);
                ?>

                    <script>
                        Tygh.chart_data = {
                            <?php 
                $_smarty_tpl->tpl_vars["graph"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["graph"]->_loop = false;
                $_smarty_tpl->tpl_vars["chart"] = new Smarty_Variable();
                $_from = $_smarty_tpl->tpl_vars['graphs']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                $_smarty_tpl->tpl_vars["graph"]->total = $_smarty_tpl->_count($_from);
                $_smarty_tpl->tpl_vars["graph"]->iteration = 0;
                foreach ($_from as $_smarty_tpl->tpl_vars["graph"]->key => $_smarty_tpl->tpl_vars["graph"]->value) {
                    $_smarty_tpl->tpl_vars["graph"]->_loop = true;
                    $_smarty_tpl->tpl_vars["chart"]->value = $_smarty_tpl->tpl_vars["graph"]->key;
                    $_smarty_tpl->tpl_vars["graph"]->iteration++;
                    $_smarty_tpl->tpl_vars["graph"]->last = $_smarty_tpl->tpl_vars["graph"]->iteration === $_smarty_tpl->tpl_vars["graph"]->total;
                    $_smarty_tpl->tpl_vars['smarty']->value['foreach']["graphs"]['last'] = $_smarty_tpl->tpl_vars["graph"]->last;
                    ?>
                                '<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['chart']->value, ENT_QUOTES, 'UTF-8');
                    ?>
': [
                                    <?php 
                    $_smarty_tpl->tpl_vars["data"] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars["data"]->_loop = false;
                    $_smarty_tpl->tpl_vars["date"] = new Smarty_Variable();
                    $_from = $_smarty_tpl->tpl_vars['graph']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    $_smarty_tpl->tpl_vars["data"]->total = $_smarty_tpl->_count($_from);
                    $_smarty_tpl->tpl_vars["data"]->iteration = 0;
                    foreach ($_from as $_smarty_tpl->tpl_vars["data"]->key => $_smarty_tpl->tpl_vars["data"]->value) {
                        $_smarty_tpl->tpl_vars["data"]->_loop = true;
                        $_smarty_tpl->tpl_vars["date"]->value = $_smarty_tpl->tpl_vars["data"]->key;
                        $_smarty_tpl->tpl_vars["data"]->iteration++;
                        $_smarty_tpl->tpl_vars["data"]->last = $_smarty_tpl->tpl_vars["data"]->iteration === $_smarty_tpl->tpl_vars["data"]->total;
                        $_smarty_tpl->tpl_vars['smarty']->value['foreach']["graph"]['last'] = $_smarty_tpl->tpl_vars["data"]->last;
                        ?>
                                        [<?php 
                        if ($_smarty_tpl->tpl_vars['is_day']->value) {
                            ?>
[<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['date']->value, ENT_QUOTES, 'UTF-8');
                            ?>
, 0, 0, 0]<?php 
                        } else {
                            ?>
new Date(<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['date']->value, ENT_QUOTES, 'UTF-8');
                            ?>
)<?php 
                        }
                        ?>
, <?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['data']->value['prev'], ENT_QUOTES, 'UTF-8');
                        ?>
, <?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['data']->value['cur'], ENT_QUOTES, 'UTF-8');
                        ?>
]<?php 
                        if (!$_smarty_tpl->getVariable('smarty')->value['foreach']['graph']['last']) {
                            ?>
,<?php 
                        }
                        ?>
                                    <?php 
                    }
                    ?>
                                ]<?php 
                    if (!$_smarty_tpl->getVariable('smarty')->value['foreach']['graphs']['last']) {
                        ?>
,<?php 
                    }
                    ?>
                            <?php 
                }
                ?>
                        };
                        Tygh.drawChart(<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['is_day']->value, ENT_QUOTES, 'UTF-8');
                ?>
);
                    </script>
                <!--statistics_tabs--></div>
            </div>
        <?php 
            }
            ?>
    </div>

    <div class="dashboard-row-bottom">
        <div class="dashboard-tables">
            <table class="dashboard-card-table dashboard-card-table-center nowrap">
                <tbody>
                    <tr>
                        <?php 
            if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['products'])) {
                ?>
                            <td>
                                <div class="dashboard-card">
                                    <div class="dashboard-card-title"><?php 
                echo $_smarty_tpl->__("active_products");
                ?>
</div>
                                    <div class="dashboard-card-content">
                                        <h3><a href="<?php 
                echo htmlspecialchars(fn_url("products.manage?status=A"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['products']['total_products']), ENT_QUOTES, 'UTF-8');
                ?>
</a></h3>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <div class="dashboard-card">
                                    <div class="dashboard-card-title"><?php 
                echo $_smarty_tpl->__("out_of_stock_products");
                ?>
</div>
                                    <div class="dashboard-card-content">
                                        <h3><a href="<?php 
                echo htmlspecialchars(fn_url("products.manage?amount_from=&amount_to=0&tracking[0]=B&tracking[1]=O"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['products']['out_of_stock_products']), ENT_QUOTES, 'UTF-8');
                ?>
</a></h3>
                                    </div>
                                </div>
                            </td>
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['customers'])) {
                ?>
                            <td>
                                <div class="dashboard-card">
                                    <div class="dashboard-card-title"><?php 
                echo $_smarty_tpl->__("registered_customers");
                ?>
</div>
                                    <div class="dashboard-card-content">
                                        <h3><a href="<?php 
                echo htmlspecialchars(fn_url("profiles.manage?user_type=C"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['customers']['registered_customers']), ENT_QUOTES, 'UTF-8');
                ?>
</a></h3>
                                    </div>
                                </div>
                            </td>
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['categories'])) {
                ?>
                            <td>
                                <div class="dashboard-card">
                                    <div class="dashboard-card-title"><?php 
                echo $_smarty_tpl->__("categories");
                ?>
</div>
                                    <div class="dashboard-card-content">
                                        <h3><a href="<?php 
                echo htmlspecialchars(fn_url("categories.manage"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['categories']['total_categories']), ENT_QUOTES, 'UTF-8');
                ?>
</a></h3>
                                    </div>
                                </div>
                            </td>
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['companies'])) {
                ?>
                            <td>
                                <div class="dashboard-card">
                                    <div class="dashboard-card-title"><?php 
                echo $_smarty_tpl->__("vendors");
                ?>
</div>
                                    <div class="dashboard-card-content">
                                        <h3><a href="<?php 
                echo htmlspecialchars(fn_url("companies.manage"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['companies']['total_companies']), ENT_QUOTES, 'UTF-8');
                ?>
</a></h3>
                                    </div>
                                </div>
                            </td>
                        <?php 
            }
            ?>
                        <?php 
            if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['pages'])) {
                ?>
                            <td>
                                <div class="dashboard-card">
                                    <div class="dashboard-card-title"><?php 
                echo $_smarty_tpl->__("web_pages");
                ?>
</div>
                                    <div class="dashboard-card-content">
                                        <h3><a href="<?php 
                echo htmlspecialchars(fn_url("pages.manage"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['pages']['total_pages']), ENT_QUOTES, 'UTF-8');
                ?>
</a></h3>
                                    </div>
                                </div>
                            </td>
                        <?php 
            }
            ?>
                    </tr>
                </tbody>
            </table>

            <?php 
            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:order_statistic"));
            $_block_repeat = true;
            echo smarty_block_hook(array('name' => "index:order_statistic"), 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' => "index:order_statistic"), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

            <?php 
            if ($_smarty_tpl->tpl_vars['user_can_view_orders']->value) {
                ?>
                <div class="dashboard-table dashboard-table-order-by-statuses">
                    <h4><?php 
                echo $_smarty_tpl->__("order_by_status");
                ?>
</h4>
                     <div class="table-wrap" id="dashboard_order_by_status">
                        <table class="table">
                            <thead>
                            <tr>
                                <th width="25%"><?php 
                echo $_smarty_tpl->__("status");
                ?>
</th>
                                <th width="25%"><?php 
                echo $_smarty_tpl->__("qty");
                ?>
</th>
                                <th width="25%"><?php 
                echo $_smarty_tpl->__('total');
                ?>
</th>
                                <th width="25%"><?php 
                echo $_smarty_tpl->__("shipping");
                ?>
</th>
                            </tr>
                            </thead>
                        </table>
                        <div class="scrollable-table">
                        <table class="table table-striped">
                            <tbody>
                                <?php 
                $_smarty_tpl->tpl_vars["order_status"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["order_status"]->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['order_by_statuses']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["order_status"]->key => $_smarty_tpl->tpl_vars["order_status"]->value) {
                    $_smarty_tpl->tpl_vars["order_status"]->_loop = true;
                    ?>
                                    <?php 
                    $_smarty_tpl->tpl_vars['url'] = new Smarty_variable(fn_url("orders.manage?is_search=Y&period=C&time_from=" . (string) $_smarty_tpl->tpl_vars['time_from']->value . "&time_to=" . (string) $_smarty_tpl->tpl_vars['time_to']->value . "&status[]=" . (string) $_smarty_tpl->tpl_vars['order_status']->value['status']), null, 0);
                    ?>
                                    <tr>
                                        <td width="25%"><a href="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['url']->value, ENT_QUOTES, 'UTF-8');
                    ?>
"><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['order_status']->value['status_name'], ENT_QUOTES, 'UTF-8');
                    ?>
</a></td>
                                        <td width="25%"><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['order_status']->value['count'], ENT_QUOTES, 'UTF-8');
                    ?>
</td>
                                        <td width="25%"><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['order_status']->value['total']), 0);
                    ?>
</td>
                                        <td width="25%"><?php 
                    echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['order_status']->value['shipping']), 0);
                    ?>
</td>
                                    </tr>
                                <?php 
                }
                ?>
                            </tbody>
                        </table>
                        </div>
                    <!--dashboard_order_by_status--></div>
                </div>
            <?php 
            }
            ?>
        </div>

        <?php 
            if (fn_check_view_permissions("logs.manage", "GET")) {
                ?>
            <div class="dashboard-activity">
                <div class="pull-right"><a href="<?php 
                echo htmlspecialchars(fn_url("logs.manage"), ENT_QUOTES, 'UTF-8');
                ?>
"><?php 
                echo $_smarty_tpl->__('show_all');
                ?>
</a></div>
                <h4><?php 
                echo $_smarty_tpl->__("recent_activity");
                ?>
</h4>
                <?php 
                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';
                }
                if (!function_exists('smarty_template_function_show_log_row')) {
                    function smarty_template_function_show_log_row($_smarty_tpl, $params)
                    {
                        $saved_tpl_vars = $_smarty_tpl->tpl_vars;
                        foreach ($_smarty_tpl->smarty->template_functions['show_log_row']['parameter'] as $key => $value) {
                            $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                        }
                        foreach ($params as $key => $value) {
                            $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value);
                        }
                        ?>
                    <?php 
                        if ($_smarty_tpl->tpl_vars['item']->value) {
                            ?>
                        <div class="item">
                            <?php 
                            $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:recent_activity"));
                            $_block_repeat = true;
                            echo smarty_block_hook(array('name' => "index:recent_activity"), null, $_smarty_tpl, $_block_repeat);
                            while ($_block_repeat) {
                                ob_start();
                                ?>

                                <?php 
                                $_smarty_tpl->tpl_vars['_type'] = new Smarty_variable("log_type_" . (string) $_smarty_tpl->tpl_vars['item']->value['type'], null, 0);
                                ?>
                                <?php 
                                $_smarty_tpl->tpl_vars['_action'] = new Smarty_variable("log_action_" . (string) $_smarty_tpl->tpl_vars['item']->value['action'], null, 0);
                                ?>

                                <?php 
                                echo $_smarty_tpl->__($_smarty_tpl->tpl_vars['_type']->value);
                                if ($_smarty_tpl->tpl_vars['item']->value['action']) {
                                    ?>
&nbsp;(<?php 
                                    echo $_smarty_tpl->__($_smarty_tpl->tpl_vars['_action']->value);
                                    ?>
)<?php 
                                }
                                ?>
:

                                <?php 
                                if ($_smarty_tpl->tpl_vars['item']->value['type'] == "users" && fn_check_view_permissions(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) {
                                    ?>
                                    <?php 
                                    if ($_smarty_tpl->tpl_vars['item']->value['content']['id']) {
                                        ?>
<a href="<?php 
                                        echo htmlspecialchars(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8');
                                        ?>
"><?php 
                                    }
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['user'], ENT_QUOTES, 'UTF-8');
                                    if ($_smarty_tpl->tpl_vars['item']->value['content']['id']) {
                                        ?>
</a><?php 
                                    }
                                    ?>
<br>
                                    
                                <?php 
                                } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "orders" && fn_check_view_permissions(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) {
                                    ?>
                                    <?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['status'], ENT_QUOTES, 'UTF-8');
                                    ?>
<br>
                                    <a href="<?php 
                                    echo htmlspecialchars(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8');
                                    ?>
"><?php 
                                    echo $_smarty_tpl->__("order");
                                    ?>
&nbsp;<?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['order'], ENT_QUOTES, 'UTF-8');
                                    ?>
</a><br>
                                <?php 
                                } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "products" && fn_check_view_permissions(fn_url("products.update?product_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) {
                                    ?>
                                    <a href="<?php 
                                    echo htmlspecialchars(fn_url("products.update?product_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8');
                                    ?>
"><?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['product'], ENT_QUOTES, 'UTF-8');
                                    ?>
</a><br>

                                <?php 
                                } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "categories" && fn_check_view_permissions(fn_url("categories.update?category_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) {
                                    ?>
                                    <a href="<?php 
                                    echo htmlspecialchars(fn_url("categories.update?category_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8');
                                    ?>
"><?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['category'], ENT_QUOTES, 'UTF-8');
                                    ?>
</a><br>                        
                                <?php 
                                }
                                ?>

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


                                <span class="date"><?php 
                                echo htmlspecialchars(smarty_modifier_date_format($_smarty_tpl->tpl_vars['item']->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');
                                ?>
</span>
                            <?php 
                                $_block_content = ob_get_clean();
                                $_block_repeat = false;
                                echo smarty_block_hook(array('name' => "index:recent_activity"), $_block_content, $_smarty_tpl, $_block_repeat);
                            }
                            array_pop($_smarty_tpl->smarty->_tag_stack);
                            ?>

                        </div>
                    <?php 
                        }
                        ?>
                <?php 
                        $_smarty_tpl->tpl_vars = $saved_tpl_vars;
                        foreach (Smarty::$global_tpl_vars as $key => $value) {
                            if (!isset($_smarty_tpl->tpl_vars[$key])) {
                                $_smarty_tpl->tpl_vars[$key] = $value;
                            }
                        }
                    }
                }
                ?>


                <div class="dashboard-activity-list">
                    <?php 
                $_smarty_tpl->tpl_vars["item"] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars["item"]->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['logs']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars["item"]->key => $_smarty_tpl->tpl_vars["item"]->value) {
                    $_smarty_tpl->tpl_vars["item"]->_loop = true;
                    ?>
                        <?php 
                    smarty_template_function_show_log_row($_smarty_tpl, array('item' => $_smarty_tpl->tpl_vars['item']->value));
                    ?>

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


<?php 
        $_smarty_tpl->_capture_stack[0][] = array("buttons", null, null);
        ob_start();
        ?>
    <?php 
        echo $_smarty_tpl->getSubTemplate("common/daterange_picker.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('id' => "dashboard_date_picker", 'extra_class' => "pull-right offset1", 'data_url' => fn_url("index.index"), 'result_ids' => "dashboard", 'start_date' => $_smarty_tpl->tpl_vars['time_from']->value, 'end_date' => $_smarty_tpl->tpl_vars['time_to']->value), 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();
        }
        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('buttons' => Smarty::$_smarty_vars['capture']['buttons'], 'no_sidebar' => true, 'title' => __("dashboard"), 'content' => Smarty::$_smarty_vars['capture']['mainbox'], 'tools' => Smarty::$_smarty_vars['capture']['tools']), 0);
        ?>


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

<?php 
            if ($_smarty_tpl->tpl_vars['show_welcome']->value) {
                ?>
    <div class="hidden cm-dialog-auto-open cm-dialog-auto-size" title="<?php 
                echo $_smarty_tpl->__("installer_complete_title");
                ?>
" id="after_install_dialog" data-ca-dialog-class="welcome-screen-dialog">
        <?php 
                $_smarty_tpl->tpl_vars["company"] = new Smarty_variable(fn_get_company_data("1"), null, 0);
                ?>
        <?php 
                if (fn_allowed_for("ULTIMATE")) {
                    ?>
            <?php 
                    ob_start();
                    echo htmlspecialchars(smarty_modifier_unpuny($_smarty_tpl->tpl_vars['company']->value['storefront']), ENT_QUOTES, 'UTF-8');
                    $_tmp1 = ob_get_clean();
                    $_smarty_tpl->tpl_vars['link_storefront'] = new Smarty_variable("http://" . $_tmp1, null, 0);
                    ?>
        <?php 
                } else {
                    ?>
            <?php 
                    ob_start();
                    echo htmlspecialchars(fn_url($_smarty_tpl->tpl_vars['config']->value['http_location']), ENT_QUOTES, 'UTF-8');
                    $_tmp2 = ob_get_clean();
                    $_smarty_tpl->tpl_vars['link_storefront'] = new Smarty_variable($_tmp2, null, 0);
                    ?>
        <?php 
                }
                ?>
        <div class="welcome-screen">
            <p>
                <?php 
                $_smarty_tpl->tpl_vars['user_data'] = new Smarty_variable(fn_get_user_info($_smarty_tpl->tpl_vars['auth']->value['user_id']), null, 0);
                ?>
                <?php 
                echo $_smarty_tpl->__("welcome_screen.administrator_info", array('[email]' => $_smarty_tpl->tpl_vars['user_data']->value['email']));
                ?>

            </p>
            <div class="welcome-location-wrapper clearfix">
                <div class="welcome-location-block pull-left center">
                    <h4 class="install-title"><?php 
                echo $_smarty_tpl->__("admin_panel");
                ?>
</h4>
                    <div class="welcome-screen-location welcome-screen-admin">
                        <div class="welcome-screen-overlay">
                            <a class="btn cm-dialog-closer welcome-screen-overlink"><?php 
                echo $_smarty_tpl->__("welcome_screen.go_admin_panel");
                ?>
</a>
                        </div>
                    </div>
                    <div class="welcome-screen-arrow"></div>
                    <p>
                        <?php 
                echo $_smarty_tpl->__("welcome_screen.go_settings_wizard");
                ?>

                    </p>
                    <?php 
                $_smarty_tpl->tpl_vars['c_url'] = new Smarty_variable(rawurlencode($_smarty_tpl->tpl_vars['config']->value['current_url']), null, 0);
                ?>
                    <a class="cm-dialog-opener cm-ajax btn btn-primary strong" data-ca-target-id="content_settings_wizard" title="<?php 
                echo $_smarty_tpl->__("settings_wizard");
                ?>
" href="<?php 
                echo htmlspecialchars(fn_url("settings_wizard.view?return_url=" . (string) $_smarty_tpl->tpl_vars['c_url']->value), ENT_QUOTES, 'UTF-8');
                ?>
" target="_blank"><?php 
                echo $_smarty_tpl->__("welcome_screen.run_settings_wizard");
                ?>
</a>
                </div>
                <div class="welcome-location-block pull-right center">
                    <h4 class="install-title"><?php 
                echo $_smarty_tpl->__("storefront");
                ?>
</h4>
                    <div class="welcome-screen-location welcome-screen-store">
                        <div class="welcome-screen-overlay">
                            <a class="btn welcome-screen-overlink" href="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['link_storefront']->value, ENT_QUOTES, 'UTF-8');
                ?>
" target="_blank"><?php 
                echo $_smarty_tpl->__("welcome_screen.go_storefront");
                ?>
</a>
                        </div>
                    </div>
                    <div class="welcome-screen-arrow"></div>
                    <p>
                        <?php 
                echo $_smarty_tpl->__("welcome_screen.learn_more_configuration");
                ?>

                    </p>
                    <a class="kbase-link" href="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['config']->value['resources']['knowledge_base'], ENT_QUOTES, 'UTF-8');
                ?>
" target="_blank"><?php 
                echo $_smarty_tpl->__("welcome_screen.knowledge_base");
                ?>
</a>
                </div>
            </div>
            <div class="welcome-screen-social center">
                <p>
                    <?php 
                echo $_smarty_tpl->__("welcome_screen.thanks", array("[product]" => @constant('PRODUCT_NAME')));
                ?>

                </p>
                <?php 
                echo $_smarty_tpl->getSubTemplate("common/share.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
                ?>

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

<?php 
    }
コード例 #3
0
ファイル: gift_certificates.php プロジェクト: askzap/ultimate
        if ($gift_cert_data['amount'] < $min || $gift_cert_data['amount'] > $max) {
            fn_set_notification('E', __('error'), __('gift_cert_error_amount', array('[max]' => $max, '[min]' => $min)));
            Tygh::$app['ajax']->assign('return_status', $gift_cert_data['status']);
        } elseif (fn_change_gift_certificate_status($_REQUEST['id'], $_REQUEST['status'], '', fn_get_notification_rules($_REQUEST))) {
            fn_set_notification('N', __('notice'), __('status_changed'));
        } else {
            fn_set_notification('E', __('error'), __('error_status_not_changed'));
            Tygh::$app['ajax']->assign('return_status', $gift_cert_data['status']);
        }
        exit;
    }
    return array(CONTROLLER_STATUS_OK, 'gift_certificates' . $suffix);
}
if ($mode == 'add') {
    if (!empty($_REQUEST['user_id'])) {
        $user_data = fn_get_user_info($_REQUEST['user_id']);
        $gift_cert_data = array('send_via' => 'E', 'recipient' => "{$user_data['firstname']} {$user_data['lastname']}", 'sender' => Registry::get('settings.Company.company_name'), 'email' => $user_data['email'], 'address' => $user_data['s_address'], 'address_2' => $user_data['s_address_2'], 'city' => $user_data['s_city'], 'country' => $user_data['s_country'], 'state' => $user_data['s_state'], 'zipcode' => $user_data['s_zipcode'], 'phone' => $user_data['phone']);
        Tygh::$app['view']->assign('gift_cert_data', $gift_cert_data);
    }
    Tygh::$app['view']->assign('templates', fn_get_gift_certificate_templates());
    Tygh::$app['view']->assign('states', fn_get_all_states());
    Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
} elseif ($mode == 'update') {
    $gift_cert_id = intval($_REQUEST['gift_cert_id']);
    $gift_cert_data = fn_get_gift_certificate_info($gift_cert_id);
    if (empty($gift_cert_data) || !empty($gift_cert_id) && !fn_check_company_id('gift_certificates', 'gift_cert_id', $gift_cert_id)) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    // [Page sections]
    Registry::set('navigation.tabs', array('detailed' => array('title' => __('detailed_info'), 'js' => true), 'log' => array('title' => __('history'), 'js' => true)));
    // [/Page sections]
コード例 #4
0
ファイル: checkout.php プロジェクト: askzap/ultimate
 if (isset($cart['payment_id'])) {
     $cart['payment_method_data'] = fn_get_payment_method_data($cart['payment_id']);
 }
 if (!empty($auth['user_id'])) {
     //if the error occurred during registration, but despite this, the registration was performed, then the variable should be cleared.
     unset($_SESSION['failed_registration']);
     if (!empty($_REQUEST['profile_id'])) {
         $cart['profile_id'] = $_REQUEST['profile_id'];
     } elseif (!empty($_REQUEST['profile']) && $_REQUEST['profile'] == 'new') {
         $cart['profile_id'] = 0;
     } elseif (empty($cart['profile_id'])) {
         $cart['profile_id'] = db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_type='P'", $auth['user_id']);
     }
     // Here check the previous and the current checksum of user_data - if they are different, recalculate the cart.
     $current_state = fn_crc32(serialize($cart['user_data']));
     $cart['user_data'] = fn_get_user_info($auth['user_id'], empty($_REQUEST['profile']), $cart['profile_id']);
     if ($current_state != fn_crc32(serialize($cart['user_data']))) {
         $cart['recalculate'] = true;
     }
 } else {
     $_user_data = fn_restore_post_data('user_data');
     if (!empty($_user_data)) {
         $_SESSION['failed_registration'] = true;
     } else {
         unset($_SESSION['failed_registration']);
     }
     fn_add_user_data_descriptions($cart['user_data']);
     if (!empty($_REQUEST['action'])) {
         Tygh::$app['view']->assign('checkout_type', $_REQUEST['action']);
     }
 }
コード例 #5
0
    return;
}
if ($mode == 'userlog') {
    $params = $_REQUEST;
    if (AREA == 'C') {
        $params['user_id'] = $auth['user_id'];
    }
    if (empty($params['user_id'])) {
        if (AREA == 'C') {
            return array(CONTROLLER_STATUS_REDIRECT, 'auth.login_form?return_url=' . urlencode(Registry::get('config.current_url')));
        } else {
            return array(CONTROLLER_STATUS_NO_PAGE);
        }
    }
    if (AREA == 'A') {
        $user = fn_get_user_info($params['user_id'], false);
        if (fn_allowed_for('ULTIMATE')) {
            if (empty($user)) {
                return array(CONTROLLER_STATUS_NO_PAGE);
            }
            if (Registry::get('settings.Stores.share_users') == 'Y' && Registry::get('runtime.company_id')) {
                $orders_ids = db_get_fields("SELECT order_id FROM ?:orders WHERE user_id = ?i AND company_id = ?i", $params['user_id'], Registry::get('runtime.company_id'));
                if (empty($orders_ids)) {
                    return array(CONTROLLER_STATUS_NO_PAGE);
                }
            }
        }
        Registry::get('view')->assign('user', $user);
    } else {
        fn_add_breadcrumb(__('reward_points_log'));
    }
コード例 #6
0
ファイル: fn.promotions.php プロジェクト: askzap/ultimate
/**
 * Promotions post processing
 *
 * @param string $status_to new order status
 * @param string $status_from original order status
 * @param array $order_info order information
 * @param array $force_notification Array with notification rules
 * @return boolean always true
 */
function fn_promotion_post_processing($status_to, $status_from, $order_info, $force_notification = array())
{
    $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true);
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($order_statuses[$status_to]['params']['notify']) && $order_statuses[$status_to]['params']['notify'] == 'Y' ? true : false);
    $status_from_is_positive = fn_status_is_positive($order_statuses[$status_from]);
    $status_to_is_positive = fn_status_is_positive($order_statuses[$status_to]);
    if (empty($order_info['promotions'])) {
        return false;
    }
    // Process numbers of usage for Open statuses
    if ($status_to != $status_from && fn_status_is_positive($order_statuses[$status_from], true) != fn_status_is_positive($order_statuses[$status_to], true)) {
        // Post processing
        if (fn_status_is_positive($order_statuses[$status_to], true)) {
            db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages + 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
        } else {
            db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages - 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
        }
    }
    if ($status_to != $status_from && $status_from_is_positive != $status_to_is_positive) {
        // Apply pending actions
        foreach ($order_info['promotions'] as $k => $v) {
            if (!empty($v['bonuses'])) {
                foreach ($v['bonuses'] as $bonus) {
                    // Assign usergroup
                    if ($bonus['bonus'] == 'give_usergroup') {
                        $is_ug_already_assigned = false;
                        if (empty($order_info['user_id'])) {
                            continue;
                        }
                        // Don't assing a disabled usergroup
                        $system_usergroups = fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H')), CART_LANGUAGE);
                        if (!empty($system_usergroups[$bonus['value']]['status']) && in_array($system_usergroups[$bonus['value']]['status'], array('A', 'H'))) {
                            if ($order_statuses[$status_to]['params']['inventory'] == 'D') {
                                // Don't assing the usergroup to the user if it's already assigned
                                $current_user_usergroups = fn_get_user_usergroups($order_info['user_id']);
                                foreach ($current_user_usergroups as $ug) {
                                    if (isset($ug['usergroup_id']) && $bonus['value'] == $ug['usergroup_id'] && in_array($ug['status'], array('A', 'H'))) {
                                        $is_ug_already_assigned = true;
                                        break;
                                    }
                                }
                                if (!$is_ug_already_assigned) {
                                    db_query("REPLACE INTO ?:usergroup_links SET user_id = ?i, usergroup_id = ?i, status = 'A'", $order_info['user_id'], $bonus['value']);
                                    $activated = true;
                                }
                            } else {
                                db_query("UPDATE ?:usergroup_links SET status = 'F' WHERE user_id = ?i AND usergroup_id = ?i", $order_info['user_id'], $bonus['value']);
                                $activated = false;
                            }
                            if ($notify_user == true && !$is_ug_already_assigned) {
                                $prefix = $activated == true ? 'activation' : 'disactivation';
                                Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_users_department', 'data' => array('user_data' => fn_get_user_info($order_info['user_id']), 'usergroups' => fn_get_usergroups(array('status' => array('A', 'H')), $order_info['lang_code']), 'usergroup_ids' => (array) $bonus['value']), 'tpl' => 'profiles/usergroup_' . $prefix . '.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
                            }
                        } else {
                            if (AREA == 'C') {
                                fn_set_notification('E', __('error'), __('unable_to_assign_usergroup'));
                            }
                        }
                    } elseif ($bonus['bonus'] == 'give_coupon') {
                        $promotion_data = fn_get_promotion_data($bonus['value']);
                        if (empty($promotion_data)) {
                            continue;
                        }
                        if ($status_to_is_positive) {
                            fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'add', 'auto_coupons', $bonus['coupon_code']);
                            if ($notify_user == true) {
                                Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_users_department', 'data' => array('promotion_data' => $promotion_data, 'bonus_data' => $bonus, 'order_info' => $order_info), 'tpl' => 'promotions/give_coupon.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
                            }
                        } else {
                            fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'remove', 'auto_coupons', $bonus['coupon_code']);
                        }
                        db_query("UPDATE ?:promotions SET conditions = ?s, conditions_hash = ?s, users_conditions_hash = ?s WHERE promotion_id = ?i", serialize($promotion_data['conditions']), fn_promotion_serialize($promotion_data['conditions']['conditions']), fn_promotion_serialize_users_conditions($promotion_data['conditions']['conditions']), $bonus['value']);
                    }
                }
            }
        }
    }
    return true;
}
コード例 #7
0
function fn_get_element_condition($table_id, $element_hash, $for_calculate = false)
{
    $auth =& $_SESSION['auth'];
    $element_id = db_get_field("SELECT element_id FROM ?:sales_reports_table_elements WHERE element_hash = ?s", $element_hash);
    $data = db_get_row("SELECT * FROM ?:sales_reports_elements WHERE element_id = ?i", $element_id);
    $cond = db_get_fields("SELECT ids FROM ?:sales_reports_table_element_conditions WHERE table_id = ?i AND element_hash = ?s", $table_id, $element_hash);
    foreach ($cond as $k => $v) {
        $data['conditions'][$v] = $v;
        if (!$for_calculate) {
            if ($data['code'] == 'product') {
                $data['conditions'][$v] = fn_get_product_data($v, $auth, CART_LANGUAGE, true, false, false);
            }
            if ($data['code'] == 'user') {
                $data['conditions'][$v] = fn_get_user_info($v, false);
            }
            if ($data['code'] == 'order') {
                $data['conditions'][$v] = db_get_row("SELECT * FROM ?:orders WHERE order_id = ?i", $v);
            }
        }
    }
    return $data = empty($data) ? false : $data;
}
コード例 #8
0
ファイル: func.php プロジェクト: arpad9/bygmarket
/**
 * Get user info
 */
function fn_twg_get_user_info($user_id)
{
    $profile = array();
    if (!$user_id) {
        $profile['user_id'] = 0;
    } else {
        $profile = fn_get_user_info($user_id);
        if (empty($profile)) {
            return false;
        }
    }
    if (AREA == 'C' && !empty($_SESSION['cart']['user_data'])) {
        $profile = array_merge($profile, $_SESSION['cart']['user_data']);
    }
    // Clear empty profile fields
    if (!empty($profile['fields'])) {
        $profile['fields'] = array_filter($profile['fields']);
    }
    $profile['ship_to_another']['profile'] = fn_check_shipping_billing($profile, fn_get_profile_fields());
    $checkout_pfields = fn_get_profile_fields('O');
    $profile['ship_to_another']['cart'] = fn_check_shipping_billing($profile, $checkout_pfields) || !fn_compare_shipping_billing($checkout_pfields);
    if ($user_id) {
        $profile['b_email'] = !empty($profile['b_email']) ? $profile['b_email'] : $profile['email'];
        $profile['s_email'] = !empty($profile['s_email']) ? $profile['s_email'] : $profile['email'];
    }
    return $profile;
}
コード例 #9
0
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: affiliate_plans.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($mode == 'html_file') {
    $_tout = 5;
    if (empty($action)) {
        $action = 'partner';
    }
    $_rurl = $action == 'partner' ? fn_url("profiles.add?aff_id=" . $auth['user_id'], 'C', 'http') : fn_url(Registry::get('config.http_location') . '/' . Registry::get('config.customer_index') . "?aff_id={$auth['user_id']}");
    $_u_data = fn_get_user_info($auth['user_id']);
    $_u_name = empty($_u_data['firstname']) ? '' : $_u_data['firstname'];
    $_u_name .= empty($_u_name) || empty($_u_data['lastname']) ? '' : ' ';
    $_u_name .= empty($_u_data['lastname']) ? '' : $_u_data['lastname'];
    $view->assign('_tout', $_tout);
    $view->assign('_rurl', $_rurl);
    $view->assign('_u_name', $_u_name);
    $file_content = trim($view->display('affiliate/redirect.tpl', false));
    // FIX-TEMPLATE
    header("Content-type: text/html");
    header("Content-disposition: attachment; filename={$action}.html");
    echo $file_content;
    exit;
}
$affiliate_plan = fn_get_affiliate_plan_data_by_partner_id($auth['user_id']);
if (!empty($affiliate_plan['plan_id'])) {
コード例 #10
0
ファイル: profiles.php プロジェクト: askzap/ultimate
 if (!empty($_REQUEST['user_id']) && !empty($_REQUEST['user_type'])) {
     if ($_REQUEST['user_id'] == $auth['user_id'] && defined('RESTRICTED_ADMIN') && !in_array($_REQUEST['user_type'], array('A', ''))) {
         return array(CONTROLLER_STATUS_REDIRECT, 'profiles.update?user_id=' . $_REQUEST['user_id']);
     }
 }
 if (fn_is_restricted_admin($_REQUEST) == true) {
     return array(CONTROLLER_STATUS_DENIED);
 }
 // copy to add below this line
 $profile_id = !empty($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : 0;
 $_uid = !empty($profile_id) ? db_get_field("SELECT user_id FROM ?:user_profiles WHERE profile_id = ?i", $profile_id) : $auth['user_id'];
 $user_id = empty($_REQUEST['user_id']) ? $mode == 'add' ? '' : $_uid : $_REQUEST['user_id'];
 if (!empty($_REQUEST['profile']) && $_REQUEST['profile'] == 'new') {
     $user_data = fn_get_user_info($user_id, false);
 } else {
     $user_data = fn_get_user_info($user_id, true, $profile_id);
 }
 $saved_user_data = fn_restore_post_data('user_data');
 if (!empty($saved_user_data)) {
     $user_data = fn_array_merge($user_data, $saved_user_data);
 }
 if ($mode == 'update') {
     if (empty($user_data)) {
         return array(CONTROLLER_STATUS_NO_PAGE);
     }
 }
 $user_data['user_id'] = empty($user_data['user_id']) ? !empty($user_id) ? $user_id : 0 : $user_data['user_id'];
 $user_data['user_type'] = empty($user_data['user_type']) ? 'C' : $user_data['user_type'];
 $user_type = !empty($_REQUEST['user_type']) ? $_REQUEST['user_type'] : $user_data['user_type'];
 $usergroups = fn_get_usergroups(fn_check_user_type_admin_area($user_type) ? array('status' => array('A', 'H')) : array('type' => 'C', 'status' => array('A', 'H')), CART_LANGUAGE);
 $auth['is_root'] = isset($auth['is_root']) ? $auth['is_root'] : '';
コード例 #11
0
ファイル: fn.companies.php プロジェクト: ambient-lounge/site
/**
 * Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled)
 *
 * @param int $company_id
 * @param string $status_to A or D
 * @param string $reason The reason of the change
 * @param string $status_from Previous status
 * @param boolean $skip_query By default false. Update query might be skipped if status is already changed.
 * @return boolean True on success or false on failure
 */
function fn_change_company_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
    /**
     * Actions before change company status
     *
     * @param int    $company_id  Company ID
     * @param string $status_to   Status to letter
     * @param string $reason      Reason text
     * @param string $status_from Status from letter
     * @param bool   $skip_query  Skip query flag
     * @param bool   $notify      Notify flag
     */
    fn_set_hook('change_company_status_pre', $company_id, $status_to, $reason, $status_from, $skip_query, $notify);
    if (empty($status_from)) {
        $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id);
    }
    if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) {
        return false;
    }
    $result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id);
    if (!$result) {
        return false;
    }
    $company_data = fn_get_company_data($company_id);
    $account = $username = '';
    if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
        if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') {
            if (!empty($company_data['request_user_id'])) {
                $password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']);
                $_set = '';
                if (empty($password_change_timestamp)) {
                    $_set = ", password_change_timestamp = 1 ";
                }
                db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']);
                $username = fn_get_user_name($company_data['request_user_id']);
                $account = 'updated';
                $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>';
                fn_set_notification('N', __('notice'), $msg, 'K');
            } else {
                $_company_data = $company_data + unserialize($company_data['request_account_data']);
                $_company_data['status'] = 'A';
                if (!empty($_company_data['request_account_name'])) {
                    $_company_data['admin_username'] = $_company_data['request_account_name'];
                }
                $user_data = fn_create_company_admin($_company_data, $_company_data['fields'], false);
                if (!empty($user_data['user_id'])) {
                    $username = $user_data['user_login'];
                    $account = 'new';
                }
            }
        }
    }
    if (empty($user_data)) {
        $user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id);
        $user_data = fn_get_user_info($user_id);
    }
    /**
     * Actions between change company status and send mail
     *
     * @param int    $company_id   Company ID
     * @param string $status_to    Status to letter
     * @param string $reason       Reason text
     * @param string $status_from  Status from letter
     * @param bool   $skip_query   Skip query flag
     * @param bool   $notify       Notify flag
     * @param array  $company_data Company data
     * @param array  $user_data    User data
     * @param bool   $result       Updated flag
     */
    fn_set_hook('change_company_status_before_mail', $company_id, $status_to, $reason, $status_from, $skip_query, $notify, $company_data, $user_data, $result);
    if ($notify && !empty($company_data['email'])) {
        $e_username = '';
        $e_account = '';
        $e_password = '';
        if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
            $e_username = $username;
            $e_account = $account;
            if ($account == 'new') {
                $e_password = $user_data['password1'];
            }
        }
        $mail_template = fn_strtolower($status_from . '_' . $status_to);
        Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A');
    }
    return $result;
}
コード例 #12
0
 protected function _getUserDataFromDatabase($email)
 {
     $user_id = fn_is_user_exists(0, array('email' => $email));
     if (!$user_id) {
         return true;
     }
     $user_info = fn_get_user_info($user_id);
     if (!empty($user_info)) {
         $data = array('BuyerRegEnd' => gmdate("Y-m-d H:i:s", $user_info['timestamp']));
         return $data;
     }
     $data = array('BuyerRegStart' => gmdate("Y-m-d H:i:s", time()));
     return $data;
 }
コード例 #13
0
ファイル: fn.users.php プロジェクト: askzap/ultimate
/**
 * Generate ekey.
 *
 * @param string $user_email
 * @return bool
 */
function fn_recover_password_generate_key($user_email, $notify = true)
{
    $result = true;
    if ($user_email) {
        $condition = '';
        if (fn_allowed_for('ULTIMATE')) {
            if (Registry::get('settings.Stores.share_users') == 'N' && AREA != 'A') {
                $condition = fn_get_company_condition('?:users.company_id');
            }
        }
        $uid = db_get_field("SELECT user_id FROM ?:users WHERE email = ?s" . $condition, $user_email);
        $u_data = fn_get_user_info($uid, false);
        if (isset($u_data['status']) && $u_data['status'] == 'D') {
            fn_set_notification('E', __('error'), __('error_account_disabled'));
            return false;
        }
        if (!empty($u_data['email'])) {
            $ekey = fn_generate_ekey($u_data['user_id'], 'U', SECONDS_IN_DAY);
            if ($notify) {
                Mailer::sendMail(array('to' => $u_data['email'], 'from' => 'default_company_users_department', 'data' => array('ekey' => $ekey, 'zone' => $u_data['user_type']), 'tpl' => 'profiles/recover_password.tpl'), fn_check_user_type_admin_area($u_data['user_type']) ? 'A' : 'C', $u_data['lang_code']);
                fn_set_notification('N', __('information'), __('text_password_recovery_instructions_sent'));
            } else {
                $result = array('company_id' => $u_data['company_id'], 'key' => $ekey, 'user_type' => $u_data['user_type']);
            }
        } else {
            fn_set_notification('E', __('error'), __('error_login_not_exists'));
            $result = false;
        }
    } else {
        fn_set_notification('E', __('error'), __('error_login_not_exists'));
        $result = false;
    }
    return $result;
}
コード例 #14
0
 //
 // Prepare customer info
 //
 $profile_fields = fn_get_profile_fields('O', $customer_auth);
 $cart['profile_id'] = empty($cart['profile_id']) ? 0 : $cart['profile_id'];
 Registry::get('view')->assign('profile_fields', $profile_fields);
 //Get user profiles
 $user_profiles = fn_get_user_profiles($customer_auth['user_id']);
 Registry::get('view')->assign('user_profiles', $user_profiles);
 //Get countries and states
 Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
 Registry::get('view')->assign('states', fn_get_all_states());
 Registry::get('view')->assign('usergroups', fn_get_usergroups('C', DESCR_SL));
 if (!empty($customer_auth['user_id']) && (empty($cart['user_data']) || !empty($_REQUEST['profile_id']) && $cart['profile_id'] != $_REQUEST['profile_id'])) {
     $cart['profile_id'] = !empty($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : 0;
     $cart['user_data'] = fn_get_user_info($customer_auth['user_id'], true, $cart['profile_id']);
     fn_filter_hidden_profile_fields($cart['user_data'], 'O');
 }
 if (!empty($cart['user_data'])) {
     $cart['ship_to_another'] = fn_check_shipping_billing($cart['user_data'], $profile_fields);
 }
 //
 // Get products info
 // and shipping rates
 //
 // Clean up saved shipping rates
 // unset($_SESSION['shipping_rates']);
 if (!empty($shipping_rates)) {
     define('CACHED_SHIPPING_RATES', true);
 }
 $cart['calculate_shipping'] = true;
コード例 #15
0
ファイル: usergroups.php プロジェクト: diedsmiling/busenika
function fn_send_usergroup_status_notification($user_id, $usergroup_ids, $status)
{
    $user_data = fn_get_user_info($user_id);
    Registry::get('view_mail')->assign('user_data', $user_data);
    Registry::get('view_mail')->assign('usergroups', fn_get_usergroups('F', $user_data['lang_code']));
    Registry::get('view_mail')->assign('usergroup_ids', $usergroup_ids);
    $prefix = $status == 'A' ? 'activation' : 'disactivation';
    fn_send_mail($user_data['email'], Registry::get('settings.Company.company_users_department'), 'profiles/usergroup_' . $prefix . '_subj.tpl', 'profiles/usergroup_' . $prefix . '.tpl', array(), $user_data['lang_code']);
}
コード例 #16
0
ファイル: fn.init.php プロジェクト: diedsmiling/busenika
/**
 * Init user
 *
 * @return boolean always true
 */
function fn_init_user()
{
    if (!empty($_SESSION['auth']['user_id'])) {
        $user_info = fn_get_user_short_info($_SESSION['auth']['user_id']);
        if (empty($user_info)) {
            // user does not exist in the database, but exists in session
            $_SESSION['auth'] = array();
        } else {
            $_SESSION['auth']['usergroup_ids'] = fn_define_usergroups(array('user_id' => $_SESSION['auth']['user_id'], 'user_type' => $user_info['user_type']));
        }
    }
    $first_init = false;
    if (empty($_SESSION['auth'])) {
        $udata = array();
        if (fn_get_cookie(AREA_NAME . '_user_id')) {
            $udata = db_get_row("SELECT user_id, user_type, tax_exempt, last_login FROM ?:users WHERE user_id = ?i AND password = ?s", fn_get_cookie(AREA_NAME . '_user_id'), fn_get_cookie(AREA_NAME . '_password'));
            fn_define('LOGGED_VIA_COOKIE', true);
        }
        $_SESSION['auth'] = fn_fill_auth($udata, isset($_SESSION['auth']['order_ids']) ? $_SESSION['auth']['order_ids'] : array());
        if (!defined('NO_SESSION')) {
            $_SESSION['cart'] = isset($_SESSION['cart']) ? $_SESSION['cart'] : array();
        }
        if (defined('LOGGED_VIA_COOKIE') && !empty($_SESSION['auth']['user_id']) || ($cu_id = fn_get_cookie('cu_id'))) {
            $first_init = true;
            if (!empty($cu_id)) {
                fn_define('COOKIE_CART', true);
            }
            // Cleanup cached shipping rates
            unset($_SESSION['shipping_rates']);
            $_utype = empty($_SESSION['auth']['user_id']) ? 'U' : 'R';
            $_uid = empty($_SESSION['auth']['user_id']) ? $cu_id : $_SESSION['auth']['user_id'];
            fn_extract_cart_content($_SESSION['cart'], $_uid, 'C', $_utype);
            fn_save_cart_content($_SESSION['cart'], $_uid, 'C', $_utype);
            if (!empty($_SESSION['auth']['user_id'])) {
                $_SESSION['cart']['user_data'] = fn_get_user_info($_SESSION['auth']['user_id']);
            }
        }
    }
    if (TIME > Registry::get('settings.cart_products_next_check')) {
        fn_define('CART_PRODUCTS_CHECK_PERIOD', SECONDS_IN_HOUR * 12);
        fn_define('CART_PRODUCTS_DELETE_TIME', TIME - SECONDS_IN_DAY * 30);
        db_query("DELETE FROM ?:user_session_products WHERE user_type = 'U' AND timestamp < ?i", CART_PRODUCTS_DELETE_TIME);
        db_query("UPDATE ?:settings SET value = ?s WHERE option_name = 'cart_products_next_check'", TIME + CART_PRODUCTS_CHECK_PERIOD);
    }
    // If administrative account has usergroup, it means the access restrictions are in action
    if (AREA == 'A' && !empty($_SESSION['auth']['usergroup_ids'])) {
        fn_define('RESTRICTED_ADMIN', true);
    }
    if (!empty($user_info) && $user_info['user_type'] == 'A') {
        if (Registry::get('settings.translation_mode') == 'Y') {
            fn_define('TRANSLATION_MODE', true);
        }
        if (Registry::get('settings.customization_mode') == 'Y') {
            if (AREA != 'A') {
                fn_define('PARSE_ALL', true);
            }
            fn_define('CUSTOMIZATION_MODE', true);
        }
    }
    fn_set_hook('user_init', $_SESSION['auth'], $user_info, $first_init);
    Registry::set('user_info', $user_info);
    Registry::get('view')->assign('auth', $_SESSION['auth']);
    Registry::get('view')->assign('user_info', $user_info);
    return true;
}
コード例 #17
0
ファイル: Orders.php プロジェクト: askzap/ultimate
 public function update($id, $params)
 {
     fn_define('ORDER_MANAGEMENT', true);
     $data = array();
     $valid_params = true;
     $status = Response::STATUS_BAD_REQUEST;
     if ($valid_params) {
         fn_clear_cart($cart, true);
         $customer_auth = fn_fill_auth(array(), array(), false, 'C');
         $cart_status = md5(serialize($cart));
         // Order info was not found or customer does not have enought permissions
         if (fn_form_cart($id, $cart, $customer_auth) && $cart_status != md5(serialize($cart))) {
             unset($params['product_groups']);
             if (empty($params['shipping_id'])) {
                 $shipping = reset($cart['shipping']);
                 if (!empty($shipping['shipping_id'])) {
                     $params['shipping_id'] = $shipping['shipping_id'];
                 }
             }
             $cart['order_id'] = $id;
             fn_calculate_cart_content($cart, $customer_auth);
             if (!empty($params['user_id'])) {
                 $cart['user_data'] = fn_get_user_info($params['user_id']);
             } elseif (!empty($params)) {
                 $cart['user_data'] = array_merge($cart['user_data'], $params);
             }
             if (!empty($cart['product_groups']) && !empty($params['shipping_id'])) {
                 foreach ($cart['product_groups'] as $key => $group) {
                     foreach ($group['shippings'] as $shipping_id => $shipping) {
                         if ($params['shipping_id'] == $shipping['shipping_id']) {
                             $cart['chosen_shipping'][$key] = $shipping_id;
                             break;
                         }
                     }
                 }
             }
             if (!empty($params['payment_id'])) {
                 if (!empty($params['payment_info'])) {
                     $cart['payment_info'] = $params['payment_info'];
                 } elseif ($params['payment_id'] != $cart['payment_id']) {
                     $cart['payment_info'] = array();
                 }
                 $cart['payment_id'] = $params['payment_id'];
             }
             if (!empty($params['products'])) {
                 $cart['products'] = $params['products'];
             }
             fn_calculate_cart_content($cart, $customer_auth);
             if (!empty($cart) && empty($cart['shipping_failed'])) {
                 $cart['parent_order_id'] = 0;
                 fn_update_payment_surcharge($cart, $customer_auth);
                 list($order_id, $order_status) = fn_update_order($cart, $id);
                 if ($order_id) {
                     if (!empty($params['status']) && fn_check_permissions('orders', 'update_status', 'admin')) {
                         fn_change_order_status($order_id, $params['status'], '', fn_get_notification_rules($params, false));
                     } elseif (!empty($order_status)) {
                         fn_change_order_status($order_id, $order_status, '', fn_get_notification_rules($params, false));
                     }
                     $status = Response::STATUS_OK;
                     $data = array('order_id' => $order_id);
                 }
             }
         }
     }
     return array('status' => $status, 'data' => $data);
 }
コード例 #18
0
ファイル: twigmo.php プロジェクト: askzap/ultimate
if (($_SERVER['REQUEST_METHOD'] == 'POST' || $format == 'jsonp') && in_array($action, $update_actions)) {
    if (empty($data)) {
        $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data'));
    }
    if ($mode == 'post') {
        if ($object == 'profile') {
            $user_data = fn_twg_get_api_data($response, $format);
            $user_data['ship_to_another'] = empty($user_data['copy_address']) ? 'Y' : '';
            if (empty($user_data['ship_to_another'])) {
                $profile_fields = fn_get_profile_fields('O');
                fn_fill_address($user_data, $profile_fields);
            }
            if (isset($user_data['fields']) && is_array($user_data['fields'])) {
                $user_data['fields'] = array_filter($user_data['fields'], 'fn_twg_filter_profile_fields');
            }
            $old_user_data = fn_get_user_info($user_data['user_id']);
            if (isset($old_user_data['company_id'])) {
                $user_data['company_id'] = $old_user_data['company_id'];
            }
            $result = fn_update_user($user_data['user_id'], $user_data, $auth, $user_data['ship_to_another'], false);
            if ($result) {
                fn_set_notification('N', '', fn_twg_get_lang_var('twgadmin_saved'));
            } else {
                if (!fn_twg_set_internal_errors($response, 'ERROR_FAIL_CREATE_USER')) {
                    $response->addError('ERROR_FAIL_CREATE_USER', __('twgadmin_fail_create_user'));
                }
                $response->returnResponse();
            }
            $profile = fn_twg_get_user_info($user_data['user_id']);
            $response->setData($profile);
        } elseif ($object == 'orders' && !empty($data['order_id'])) {
コード例 #19
0
ファイル: func.php プロジェクト: heg-arc-ne/cscart
function fn_hybrid_auth_login($user_data, $auth_data, $provider)
{
    if (empty($user_data['user_id'])) {
        if (!empty($auth_data->verifiedEmail)) {
            $email = $auth_data->verifiedEmail;
        } elseif (!empty($auth_data->email)) {
            $email = $auth_data->email;
        } elseif (!empty($_REQUEST['user_email'])) {
            $email = $_REQUEST['user_email'];
            $auth_data->email = $email;
        } elseif (Registry::get('addons.hybrid_auth.autogen_email') == 'Y') {
            $email = $provider . '-' . $auth_data->identifier . '@example.com';
            $auth_data->email = $email;
        } else {
            $email = '';
        }
        if (empty($email)) {
            $user_status = LOGIN_STATUS_NOT_FOUND_EMAIL;
        } else {
            $user_id = fn_is_user_exists(0, array('email' => $email));
            if (empty($user_id)) {
                $user_data = fn_hybrid_auth_create_user($auth_data, $provider);
                fn_hybrid_auth_link_provider($user_data['user_id'], $auth_data->identifier, $provider);
            } else {
                $user_status = LOGIN_STATUS_USER_EXIST;
                $user_data = fn_get_user_info($user_id);
            }
        }
    }
    if (empty($user_status)) {
        if (!empty($user_data['user_id'])) {
            $user_status = fn_login_user($user_data['user_id']);
        } else {
            $user_status = LOGIN_STATUS_USER_NOT_FOUND;
        }
    }
    $redirect_url = !empty($_REQUEST['redirect_url']) ? fn_url($_REQUEST['redirect_url']) : fn_url();
    if ($user_status == LOGIN_STATUS_USER_DISABLED) {
        fn_set_notification('E', __('error'), __('error_account_disabled'));
    } elseif ($user_status == LOGIN_STATUS_USER_NOT_FOUND) {
        fn_delete_notification('user_exist');
        fn_set_notification('W', __('warning'), __('hybrid_auth.cant_create_profile'));
    } elseif ($user_status == LOGIN_STATUS_USER_EXIST) {
        $_SESSION['hybrid_auth']['email'] = $user_data['email'];
        $_SESSION['hybrid_auth']['identifier'] = $auth_data->identifier;
        $_SESSION['hybrid_auth']['provider'] = $provider;
        $_SESSION['hybrid_auth']['redirect_url'] = $redirect_url;
        $redirect_url = fn_url('auth.connect_social');
    } elseif ($user_status == LOGIN_STATUS_NOT_FOUND_EMAIL) {
        $_SESSION['hybrid_auth']['identifier'] = $auth_data->identifier;
        $_SESSION['hybrid_auth']['provider'] = $provider;
        $_SESSION['hybrid_auth']['redirect_url'] = $redirect_url;
        $redirect_url = fn_url('auth.specify_email');
    }
    return $redirect_url;
}
コード例 #20
0
ファイル: fn.cart.php プロジェクト: heg-arc-ne/cscart
/**
 * Update steps data handler
 *
 * @param  array $cart   Cart
 * @param  array $auth   Auth
 * @param  array $params Params
 * @return array
 */
function fn_checkout_update_steps(&$cart, &$auth, $params)
{
    $redirect_params = array();
    $user_data = !empty($params['user_data']) ? $params['user_data'] : array();
    unset($user_data['user_type']);
    if (!empty($auth['user_id'])) {
        if (isset($user_data['profile_id'])) {
            if (empty($user_data['profile_id'])) {
                $user_data['profile_type'] = 'S';
            }
            $profile_id = $user_data['profile_id'];
        } elseif (!empty($cart['profile_id'])) {
            $profile_id = $cart['profile_id'];
        } else {
            $profile_id = db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_type = 'P'", $auth['user_id']);
        }
        $user_data['user_id'] = $auth['user_id'];
        $current_user_data = fn_get_user_info($auth['user_id'], true, $profile_id);
        if ($profile_id != NULL) {
            $cart['profile_id'] = $profile_id;
        }
        $errors = false;
        // Update contact information
        if (($params['update_step'] == 'step_one' || $params['update_step'] == 'step_two') && !empty($user_data['email'])) {
            // Check email
            $email_exists = fn_is_user_exists($auth['user_id'], $user_data);
            if (!empty($email_exists)) {
                fn_set_notification('E', __('error'), __('error_user_exists'));
                $redirect_params['edit_step'] = $params['update_step'];
                $errors = true;
                $params['next_step'] = $params['update_step'];
            }
        }
        // Update billing/shipping information
        if ($params['update_step'] == 'step_two' || $params['update_step'] == 'step_one' && !$errors) {
            if (!empty($user_data)) {
                $user_data = fn_array_merge($current_user_data, $user_data);
                $user_data['user_type'] = !empty($current_user_data['user_type']) ? $current_user_data['user_type'] : AREA;
                $user_data = fn_fill_contact_info_from_address($user_data);
            }
            $user_data = fn_array_merge($current_user_data, $user_data);
            if (empty($params['ship_to_another'])) {
                $profile_fields = fn_get_profile_fields('O');
                fn_fill_address($user_data, $profile_fields);
            }
            // Check if we need to send notification with new email to customer
            $email = db_get_field('SELECT email FROM ?:users WHERE user_id = ?i', $auth['user_id']);
            $send_notification = false;
            if (isset($user_data['email']) && $user_data['email'] != $email) {
                $send_notification = true;
            }
            list($user_id, $profile_id) = fn_update_user($auth['user_id'], $user_data, $auth, !empty($params['ship_to_another']), $send_notification, false);
            $cart['profile_id'] = $profile_id;
        }
        // Add/Update additional fields
        if (!empty($user_data['fields'])) {
            fn_store_profile_fields($user_data, array('U' => $auth['user_id'], 'P' => $profile_id), 'UP');
            // FIXME
        }
    } elseif (Registry::get('settings.Checkout.disable_anonymous_checkout') != 'Y') {
        if (empty($auth['user_id']) && !empty($user_data['email'])) {
            $email_exists = fn_is_user_exists(0, $user_data);
            if (!empty($email_exists)) {
                fn_set_notification('E', __('error'), __('error_user_exists'));
                fn_save_post_data('user_data');
                if (!empty($params['guest_checkout'])) {
                    $redirect_params['edit_step'] = $params['step_two'];
                    $redirect_params['guest_checkout'] = 1;
                }
                return $redirect_params;
            }
        }
        if (isset($user_data['fields'])) {
            $fields = fn_array_merge(isset($cart['user_data']['fields']) ? $cart['user_data']['fields'] : array(), $user_data['fields']);
        }
        if ($params['update_step'] == 'step_two' && !empty($user_data)) {
            $user_data = fn_fill_contact_info_from_address($user_data);
        }
        $cart['user_data'] = fn_array_merge($cart['user_data'], $user_data);
        // Fill shipping info with billing if needed
        if (empty($params['ship_to_another']) && $params['update_step'] == 'step_two') {
            $profile_fields = fn_get_profile_fields('O');
            fn_fill_address($cart['user_data'], $profile_fields);
        }
        if (!empty($cart['user_data']['b_vat_id']) && !empty($cart['user_data']['b_country'])) {
            if (fn_check_vat_id($user_data['b_vat_id'], $cart['user_data']['b_country'])) {
                fn_set_notification('N', __('notice'), __('vat_id_number_is_valid'));
            } else {
                fn_set_notification('E', __('error'), __('vat_id_number_is_not_valid'));
                $cart['user_data']['b_vat_id'] = '';
                return $redirect_params;
            }
        } elseif (isset($user_data['b_vat_id'])) {
            $user_data['b_vat_id'] = '';
        }
    }
    if (!empty($params['next_step'])) {
        $redirect_params['edit_step'] = $params['next_step'];
    }
    if (!empty($params['shipping_ids'])) {
        fn_checkout_update_shipping($cart, $params['shipping_ids']);
    }
    if (!empty($params['payment_id'])) {
        $cart['payment_id'] = (int) $params['payment_id'];
        if (!empty($params['payment_info'])) {
            $cart['extra_payment_info'] = $params['payment_info'];
            if (!empty($cart['extra_payment_info']['card_number'])) {
                $cart['extra_payment_info']['secure_card_number'] = preg_replace('/^(.+?)([0-9]{4})$/i', '***-$2', $cart['extra_payment_info']['card_number']);
            }
        } else {
            unset($cart['extra_payment_info']);
        }
        fn_update_payment_surcharge($cart, $auth);
        fn_save_cart_content($cart, $auth['user_id']);
    }
    if (!empty($params['customer_notes'])) {
        $cart['notes'] = $params['customer_notes'];
    }
    // Recalculate the cart
    $cart['recalculate'] = true;
    if (!empty($params['next_step']) && ($params['next_step'] == 'step_three' || $params['next_step'] == 'step_four')) {
        $cart['calculate_shipping'] = true;
    }
    $shipping_calculation_type = Registry::get('settings.General.estimate_shipping_cost') == 'Y' || !empty($completed_steps['step_two']) ? 'A' : 'S';
    list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $auth, $shipping_calculation_type, true, 'F');
    $shipping_hash = fn_get_shipping_hash($cart['product_groups']);
    if (!empty($_SESSION['shipping_hash']) && $_SESSION['shipping_hash'] != $shipping_hash && $params['next_step'] == 'step_four' && $cart['shipping_required']) {
        if (!empty($cart['chosen_shipping'])) {
            fn_set_notification('W', __('important'), __('text_shipping_rates_changed'));
        }
        $cart['chosen_shipping'] = array();
        $redirect_params['edit_step'] = 'step_three';
        return $redirect_params;
    }
    return $redirect_params;
}
コード例 #21
0
/**
 * Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled)
 *
 * @param int $company_id
 * @param string $status_to A or D
 * @param string $reason The reason of the change
 * @param string $status_from Previous status
 * @param boolean $skip_query By default false. Update query might be skipped if status is already changed.
 * @return boolean True on success or false on failure
 */
function fn_companies_change_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
    if (empty($status_from)) {
        $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id);
    }
    if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) {
        return false;
    }
    $result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id);
    if (!$result) {
        return false;
    }
    $company_data = fn_get_company_data($company_id);
    $account = $username = '';
    if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
        if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') {
            if (!empty($company_data['request_user_id'])) {
                $password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']);
                $_set = '';
                if (empty($password_change_timestamp)) {
                    $_set = ", password_change_timestamp = 1 ";
                }
                db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']);
                $username = fn_get_user_name($company_data['request_user_id']);
                $account = 'updated';
                $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>';
                fn_set_notification('N', __('notice'), $msg, 'K');
            } else {
                $user_data = array();
                if (!empty($company_data['request_account_name'])) {
                    $user_data['user_login'] = $company_data['request_account_name'];
                } else {
                    $user_data['user_login'] = $company_data['email'];
                }
                $request_account_data = unserialize($company_data['request_account_data']);
                $user_data['fields'] = $request_account_data['fields'];
                $user_data['firstname'] = $user_data['b_firstname'] = $user_data['s_firstname'] = $request_account_data['admin_firstname'];
                $user_data['lastname'] = $user_data['b_lastname'] = $user_data['s_lastname'] = $request_account_data['admin_lastname'];
                $user_data['user_type'] = 'V';
                $user_data['password1'] = fn_generate_password();
                $user_data['password2'] = $user_data['password1'];
                $user_data['status'] = 'A';
                $user_data['company_id'] = $company_id;
                $user_data['email'] = $company_data['email'];
                $user_data['company'] = $company_data['company'];
                $user_data['last_login'] = 0;
                $user_data['lang_code'] = $company_data['lang_code'];
                $user_data['password_change_timestamp'] = 0;
                // Copy vendor admin billing and shipping addresses from the company's credentials
                $user_data['b_address'] = $user_data['s_address'] = $company_data['address'];
                $user_data['b_city'] = $user_data['s_city'] = $company_data['city'];
                $user_data['b_country'] = $user_data['s_country'] = $company_data['country'];
                $user_data['b_state'] = $user_data['s_state'] = $company_data['state'];
                $user_data['b_zipcode'] = $user_data['s_zipcode'] = $company_data['zipcode'];
                list($added_user_id, $null) = fn_update_user(0, $user_data, $null, false, false);
                if ($added_user_id) {
                    $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $added_user_id) . '">' . __('you_can_edit_account_details') . '</a>';
                    fn_set_notification('N', __('notice'), $msg, 'K');
                    $username = $user_data['user_login'];
                    $account = 'new';
                }
            }
        }
    }
    if (empty($user_data)) {
        $user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id);
        $user_data = fn_get_user_info($user_id);
    }
    if ($notify && !empty($company_data['email'])) {
        $e_username = '';
        $e_account = '';
        $e_password = '';
        if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
            $e_username = $username;
            $e_account = $account;
            if ($account == 'new') {
                $e_password = $user_data['password1'];
            }
        }
        $mail_template = fn_strtolower($status_from . '_' . $status_to);
        Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A');
    }
    return $result;
}
コード例 #22
0
/**
 * Prepare and sends user data if user placed order.
 * event - place_order
 *
 * @return bool
 */
function fn_triggmine_place_order($order_id, $action, $order_status, $cart, $auth)
{
    if ($order_id) {
        $userInfo = array();
        $user_id = $auth['user_id'];
        $u_data = fn_get_user_info($user_id, false);
        if (!empty($u_data['email'])) {
            $userInfo['BuyerEmail'] = $u_data['email'];
        }
        if (!empty($u_data['firstname'])) {
            $userInfo['FirstName'] = $u_data['firstname'];
        }
        if (!empty($u_data['lastname'])) {
            $userInfo['LastName'] = $u_data['lastname'];
        }
        if (!empty($u_data['birthday'])) {
            $userInfo['BuyerBirthday'] = $u_data['birthday'];
        }
        if (!empty($u_data['phone'])) {
            $userInfo['PhoneNumber'] = $u_data['phone'];
        }
        $integrator = Triggmine_Integrator_CS_Cart::singleton();
        $integrator->_onCartPurchased($userInfo);
        return true;
    } else {
        return false;
    }
}
コード例 #23
0
ファイル: func.php プロジェクト: ambient-lounge/site
function fn_em_get_subscriber_name()
{
    $name = '';
    if (!empty(Tygh::$app['session']['cart']['user_data']['firstname'])) {
        $name = Tygh::$app['session']['cart']['user_data']['firstname'];
    } elseif (!empty(Tygh::$app['session']['auth']['user_id'])) {
        $user_info = fn_get_user_info(Tygh::$app['session']['auth']['user_id'], false);
        $name = $user_info['firstname'];
    }
    return $name;
}
コード例 #24
0
/**
 * Promotions post processing
 *
 * @param char $status_to new order status
 * @param char $status_from original order status
 * @param array $order_info order information
 * @param bool $force_notification force user notification
 * @return boolean always true
 */
function fn_promotion_post_processing($status_to, $status_from, $order_info, $force_notification = array())
{
    $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true);
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($order_statuses[$status_to]['notify']) && $order_statuses[$status_to]['notify'] == 'Y' ? true : false);
    if ($status_to != $status_from && $order_statuses[$status_to]['inventory'] != $order_statuses[$status_from]['inventory']) {
        if (empty($order_info['promotions'])) {
            return false;
        }
        // Post processing
        if ($order_statuses[$status_to]['inventory'] == 'D' && $order_statuses[$status_from]['inventory'] == 'I') {
            db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages + 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
        } else {
            db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages - 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
        }
        // Apply pending actions
        foreach ($order_info['promotions'] as $k => $v) {
            if (!empty($v['bonuses'])) {
                foreach ($v['bonuses'] as $bonus) {
                    // Assign usergroup
                    if ($bonus['bonus'] == 'give_usergroup') {
                        $is_ug_already_assigned = false;
                        if (empty($order_info['user_id'])) {
                            continue;
                        }
                        // Don't assing a disabled usergroup
                        $system_usergroups = fn_get_usergroups('C', CART_LANGUAGE);
                        if (!empty($system_usergroups[$bonus['value']]['status']) && $system_usergroups[$bonus['value']]['status'] == 'A') {
                            if ($order_statuses[$status_to]['inventory'] == 'D' && $order_statuses[$status_from]['inventory'] == 'I') {
                                // Don't assing the usergroup to the user if it's already assigned
                                $current_user_usergroups = fn_get_user_usergroups($order_info['user_id']);
                                foreach ($current_user_usergroups as $ug) {
                                    if (isset($ug['usergroup_id']) && $bonus['value'] == $ug['usergroup_id'] && $ug['status'] == 'A') {
                                        $is_ug_already_assigned = true;
                                        break;
                                    }
                                }
                                if (!$is_ug_already_assigned) {
                                    db_query("REPLACE INTO ?:usergroup_links SET user_id = ?i, usergroup_id = ?i, status = 'A'", $order_info['user_id'], $bonus['value']);
                                    $activated = true;
                                }
                            } else {
                                db_query("UPDATE ?:usergroup_links SET status = 'F' WHERE user_id = ?i AND usergroup_id = ?i", $order_info['user_id'], $bonus['value']);
                                $activated = false;
                            }
                            if ($notify_user == true && !$is_ug_already_assigned) {
                                Registry::get('view_mail')->assign('user_data', fn_get_user_info($order_info['user_id']));
                                Registry::get('view_mail')->assign('usergroups', fn_get_usergroups('F', $order_info['lang_code']));
                                Registry::get('view_mail')->assign('usergroup_ids', (array) $bonus['value']);
                                $prefix = $activated == true ? 'activation' : 'disactivation';
                                fn_send_mail($order_info['email'], Registry::get('settings.Company.company_users_department'), 'profiles/usergroup_' . $prefix . '_subj.tpl', 'profiles/usergroup_' . $prefix . '.tpl', array(), $order_info['lang_code']);
                            }
                        } else {
                            if (AREA == 'C') {
                                fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('unable_to_assign_usergroup'));
                            }
                        }
                    } elseif ($bonus['bonus'] == 'give_coupon') {
                        $promotion_data = fn_get_promotion_data($bonus['value']);
                        if (empty($promotion_data)) {
                            continue;
                        }
                        if ($order_statuses[$status_to]['inventory'] == 'D' && $order_statuses[$status_from]['inventory'] == 'I') {
                            fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'add', 'auto_coupons', $bonus['coupon_code']);
                            if ($notify_user == true) {
                                Registry::get('view_mail')->assign('promotion_data', $promotion_data);
                                Registry::get('view_mail')->assign('bonus_data', $bonus);
                                Registry::get('view_mail')->assign('order_info', $order_info);
                                fn_send_mail($order_info['email'], Registry::get('settings.Company.company_users_department'), 'promotions/give_coupon_subj.tpl', 'promotions/give_coupon.tpl', array(), $order_info['lang_code']);
                            }
                        } else {
                            fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'remove', 'auto_coupons', $bonus['coupon_code']);
                        }
                        db_query("UPDATE ?:promotions SET conditions = ?s, conditions_hash = ?s WHERE promotion_id = ?i", serialize($promotion_data['conditions']), fn_promotion_serialize($promotion_data['conditions']['conditions']), $bonus['value']);
                    }
                }
            }
        }
    }
    return true;
}
コード例 #25
0
ファイル: myob_export.php プロジェクト: diedsmiling/busenika
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: myob_export.php 10012 2010-07-08 08:33:34Z alexions $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'export_profiles') {
        header('Content-type: text/csv');
        header('Content-disposition: attachment; filename=shop-customers' . date('Ymd') . '.txt');
        foreach ($_REQUEST['user_ids'] as $k => $v) {
            $users[$k] = fn_get_user_info($v);
        }
        $view->assign('users', $users);
        $view->display('addons/myob/views/users/components/export_to_myob.tpl');
        exit;
    }
    if ($mode == 'export_orders') {
        header('Content-type: text/csv');
        header('Content-disposition: attachment; filename=shop-orders' . date('Ymd') . '.txt');
        foreach ($_REQUEST['order_ids'] as $k => $v) {
            $orders[$k] = fn_get_order_info($v);
            $orders[$k]['order_date'] = date('j/n/Y', $orders[$k]['timestamp']);
            $orders[$k]['paid_amount'] = 0;
            //TODO: Update this!
            foreach ($orders[$k]['items'] as $ik => $iv) {
                $option_desc = "";
コード例 #26
0
ファイル: twigmo.php プロジェクト: arpad9/bygmarket
     }
     if (isset($user_data['fields']) && is_array($user_data['fields'])) {
         $user_data['fields'] = array_filter($user_data['fields'], 'fn_twg_filter_profile_fields');
     }
     $result = fn_update_user($user_data['user_id'], $user_data, $_SESSION['auth'], !$user_data['copy_address'], $notify_user);
     if (!$result) {
         if (!fn_twg_set_internal_errors($response, 'ERROR_FAIL_CREATE_USER')) {
             $response->addError('ERROR_FAIL_CREATE_USER', __('twgadmin_fail_create_user'));
         }
         $response->returnResponse();
     }
     if ($_SESSION['auth']['user_id'] == 0 && version_compare(PRODUCT_VERSION, '4.3.1', '>=')) {
         list($user_id, $profile_id) = $result;
         fn_login_user($user_id);
     }
     $_SESSION['cart']['user_data'] = fn_get_user_info($_SESSION['auth']['user_id']);
     $profile = fn_twg_get_user_info($_SESSION['auth']['user_id']);
     $profile = array_merge($profile, array('cart' => fn_twg_api_get_session_cart($_SESSION['cart'], $lang_code)));
     $response->setData($profile);
 } elseif ($meta['object'] == 'cart_profile') {
     // For anonymous chekcout
     $user_data = fn_twg_get_api_data($response, $format);
     fn_fill_user_fields($user_data);
     if ($user_data['copy_address']) {
         $profile_fields = fn_get_profile_fields('O');
         fn_fill_address($user_data, $profile_fields, false);
     }
     $_SESSION['cart']['user_data'] = $user_data;
 } elseif ($meta['object'] == 'payment_methods') {
     $cart =& $_SESSION['cart'];
     $auth =& $_SESSION['auth'];
コード例 #27
0
ファイル: auth.php プロジェクト: diedsmiling/busenika
        exit;
    }
    if (!empty($auth['user_id'])) {
        return array(CONTROLLER_STATUS_REDIRECT, $index_script);
    }
    fn_add_breadcrumb(fn_get_lang_var('my_account'));
} elseif ($mode == 'password_change' && AREA == 'A') {
    if (defined('AJAX_REQUEST') && empty($auth)) {
        exit;
    }
    if (empty($auth['user_id'])) {
        return array(CONTROLLER_STATUS_REDIRECT, $index_script);
    }
    fn_add_breadcrumb(fn_get_lang_var('my_account'));
    $profile_id = 0;
    $user_data = fn_get_user_info($auth['user_id'], true, $profile_id);
    $view->assign('user_data', $user_data);
    $view->assign('view_mode', 'simple');
} elseif ($mode == 'change_login') {
    $auth = $_SESSION['auth'];
    if (!empty($auth['user_id'])) {
        // Log user logout
        fn_log_event('users', 'session', array('user_id' => $auth['user_id'], 'time' => TIME - $auth['this_login'], 'timeout' => false));
    }
    unset($_SESSION['auth'], $_SESSION['cart']['user_data']);
    fn_delete_cookies(AREA_NAME . '_user_id', AREA_NAME . '_password');
    return array(CONTROLLER_STATUS_OK, fn_url('checkout.checkout'));
}
function fn_auth_routines($request)
{
    $status = true;
コード例 #28
0
ファイル: cart.post.php プロジェクト: askzap/ultimate
 $item_types = fn_get_cart_content_item_types();
 if (empty($_REQUEST['user_id'])) {
     $carts_list = Tygh::$app['view']->getTemplateVars('carts_list');
     if (!empty($carts_list)) {
         $all_wishlist_products = array();
         if (fn_allowed_for('ULTIMATE')) {
             foreach ($carts_list as $key => $cart_data) {
                 $all_wishlist_products[$key] = db_get_array("SELECT COUNT(item_id) as count" . " FROM ?:user_session_products" . " WHERE user_id = ?i AND company_id = ?i AND type = 'W'" . " GROUP BY user_id, company_id", $cart_data['user_id'], $cart_data['company_id']);
                 $carts_list[$key]['wishlist_products'] = !empty($all_wishlist_products[$key][0]['count']) ? $all_wishlist_products[$key][0]['count'] : 0;
                 $carts_list[$key]['user_data'] = empty($carts_list[$key]['user_data']) ? fn_get_user_info($cart_data['user_id'], true) : $carts_list[$key]['user_data'];
             }
         } else {
             foreach ($carts_list as $key => $cart_data) {
                 $all_wishlist_products[$key] = db_get_array("SELECT COUNT(item_id) as count" . " FROM ?:user_session_products" . " WHERE user_id = ?i AND type = 'W'" . " GROUP BY user_id", $cart_data['user_id']);
                 $carts_list[$key]['wishlist_products'] = !empty($all_wishlist_products[$key][0]['count']) ? $all_wishlist_products[$key][0]['count'] : 0;
                 $carts_list[$key]['user_data'] = empty($carts_list[$key]['user_data']) ? fn_get_user_info($cart_data['user_id'], true) : $carts_list[$key]['user_data'];
             }
         }
     }
     Tygh::$app['view']->assign('carts_list', $carts_list);
 } else {
     if (fn_allowed_for('ULTIMATE') && !empty($_REQUEST['c_company_id'])) {
         $products = db_get_array("SELECT ?:user_session_products.item_id, ?:user_session_products.item_type, ?:user_session_products.product_id, ?:user_session_products.amount, ?:user_session_products.price, ?:user_session_products.extra, ?:product_descriptions.product" . " FROM ?:user_session_products" . " LEFT JOIN ?:product_descriptions ON ?:user_session_products.product_id = ?:product_descriptions.product_id AND ?:product_descriptions.lang_code = ?s" . " WHERE ?:user_session_products.user_id = ?i AND ?:user_session_products.company_id = ?i AND ?:user_session_products.type = 'W' AND ?:user_session_products.item_type IN (?a)", DESCR_SL, $_REQUEST['user_id'], $_REQUEST['c_company_id'], $item_types);
     } else {
         $products = db_get_array("SELECT ?:user_session_products.item_id, ?:user_session_products.item_type, ?:user_session_products.product_id, ?:user_session_products.amount, ?:user_session_products.price, ?:user_session_products.extra, ?:product_descriptions.product" . " FROM ?:user_session_products" . " LEFT JOIN ?:product_descriptions ON ?:user_session_products.product_id = ?:product_descriptions.product_id AND ?:product_descriptions.lang_code = ?s" . " WHERE ?:user_session_products.user_id = ?i AND ?:user_session_products.type = 'W' AND ?:user_session_products.item_type IN (?a)", DESCR_SL, $_REQUEST['user_id'], $item_types);
     }
     if (!empty($products)) {
         foreach ($products as $key => $product) {
             $products[$key]['extra'] = unserialize($product['extra']);
         }
     }
コード例 #29
0
ファイル: TwigmoOrder.php プロジェクト: askzap/ultimate
 /**
  * Return order/orders info after the order placing
  * @param int   $order_id
  * @param array $response
  */
 public static function returnPlacedOrders($order_id, &$response, $items_per_page, $lang_code)
 {
     $order = self::getOrderInfo($order_id);
     $_error = false;
     $status = db_get_field('SELECT status FROM ?:orders WHERE order_id=?i', $order_id);
     if ($status == STATUS_PARENT_ORDER) {
         $child_orders = db_get_hash_single_array("SELECT order_id, status FROM ?:orders WHERE parent_order_id = ?i", array('order_id', 'status'), $order_id);
         $status = reset($child_orders);
         $order['child_orders'] = array_keys($child_orders);
     }
     if (!in_array($status, fn_get_order_paid_statuses())) {
         $_error = true;
         if ($status != 'B') {
             if (!empty($child_orders)) {
                 array_unshift($child_orders, $order_id);
             } else {
                 $child_orders = array();
                 $child_orders[] = $order_id;
             }
             $order_id_field = $status == 'N' ? 'processed_order_id' : 'failed_order_id';
             $_SESSION['cart'][$order_id_field] = $child_orders;
             $cart =& $_SESSION['cart'];
             if (!empty($cart['failed_order_id'])) {
                 $_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id'];
                 $_order_id = reset($_ids);
                 $_payment_info = db_get_field("SELECT data\n                         FROM ?:order_data\n                         WHERE order_id = ?i AND type = 'P'", $_order_id);
                 if (!empty($_payment_info)) {
                     $_payment_info = unserialize(fn_decrypt_text($_payment_info));
                 }
                 $_msg = !empty($_payment_info['reason_text']) ? $_payment_info['reason_text'] : '';
                 $_msg .= empty($_msg) ? __('text_order_placed_error') : '';
                 $response->addError('ERROR_FAIL_POST_ORDER', $_msg);
                 $cart['processed_order_id'] = $cart['failed_order_id'];
                 unset($cart['failed_order_id']);
             } elseif (!fn_twg_set_internal_errors($response, 'ERROR_FAIL_POST_ORDER')) {
                 $response->addError('ERROR_FAIL_POST_ORDER', __('fail_post_order', $lang_code));
             }
         } else {
             if (!fn_twg_set_internal_errors($response, 'ERROR_ORDER_BACKORDERED')) {
                 $response->addError('ERROR_ORDER_BACKORDERED', __('text_order_backordered', $lang_code));
             }
         }
         $response->returnResponse();
     }
     $auth =& $_SESSION['auth'];
     $user = fn_get_user_info($auth['user_id']);
     $profile_points = !empty($user['points']) ? $user['points'] : 0;
     if (empty($order['child_orders'])) {
         $response->setData(array('order' => $order, 'profile_points' => $profile_points));
     } else {
         $params = array();
         if (empty($auth['user_id'])) {
             $params['order_id'] = $auth['order_ids'];
         } else {
             $params['user_id'] = $auth['user_id'];
         }
         list($orders, , $totals) = fn_get_orders($params, $items_per_page, true);
         $response->setMeta(!empty($totals['gross_total']) ? $totals['gross_total'] : 0, 'gross_total');
         $response->setMeta(!empty($totals['totally_paid']) ? $totals['totally_paid'] : 0, 'totally_paid');
         $response->setMeta($order, 'order');
         $response->setResponseList(TwigmoOrder::getOrdersAsApiList($orders, $lang_code));
         $response->setData($profile_points, 'profile_points');
         $pagination_params = array('items_per_page' => !empty($items_per_page) ? $items_per_page : TWG_RESPONSE_ITEMS_LIMIT, 'page' => !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1);
         fn_twg_set_response_pagination($response, $pagination_params);
     }
 }
コード例 #30
0
ファイル: cart.php プロジェクト: askzap/ultimate
                    $carts_list[$key]['cart_products'] = $all_cart_products[$key]['count'];
                    $carts_list[$key]['cart_all_products'] = $all_cart_products[$key]['sum'];
                    $carts_list[$key]['total'] = $all_cart_products[$key]['total'];
                    $carts_list[$key]['user_data'] = fn_get_user_info($cart_data['user_id'], true);
                    $carts_list[$key]['ip_address'] = fn_ip_from_db($all_cart_products[$key]['ip_address']);
                }
                $_SESSION['abandoned_carts'][$cart_data['company_id']][] = $cart_data['user_id'];
            }
        } else {
            foreach ($carts_list as $key => $cart_data) {
                $all_cart_products[$key] = db_get_row("SELECT SUM(amount) as count, SUM(amount) as sum, SUM(amount * price) as total, ip_address" . " FROM ?:user_session_products" . " WHERE user_id = ?i AND item_type IN (?a) AND type = 'C'" . " GROUP BY ?:user_session_products.user_id", $cart_data['user_id'], $item_types);
                if (!empty($all_cart_products[$key])) {
                    $carts_list[$key]['cart_products'] = $all_cart_products[$key]['count'];
                    $carts_list[$key]['cart_all_products'] = $all_cart_products[$key]['sum'];
                    $carts_list[$key]['total'] = $all_cart_products[$key]['total'];
                    $carts_list[$key]['user_data'] = fn_get_user_info($cart_data['user_id'], true);
                    $carts_list[$key]['ip_address'] = fn_ip_from_db($all_cart_products[$key]['ip_address']);
                }
                $_SESSION['abandoned_carts'][] = $cart_data['user_id'];
            }
        }
    }
    Tygh::$app['view']->assign('carts_list', $carts_list);
    Tygh::$app['view']->assign('search', $search);
}
function fn_delete_user_cart($user_ids, $data = '')
{
    $condition = db_quote(' AND user_id IN (?a)', $user_ids);
    fn_set_hook('delete_user_cart', $user_ids, $condition, $data);
    db_query("DELETE FROM ?:user_session_products WHERE 1 {$condition}");
    return true;