Пример #1
0
 public function create($params)
 {
     $status = Response::STATUS_BAD_REQUEST;
     $data = array();
     $valid_params = true;
     if (empty($params['type'])) {
         $params['type'] = STATUSES_ORDER;
     }
     if (empty($params['description'])) {
         $data['message'] = __('api_required_field', array('[field]' => 'description'));
         $valid_params = false;
     }
     if ($valid_params == true) {
         unset($params['status_id']);
         unset($params['status']);
         $status_name = fn_update_status('', $params, $params['type']);
         $status_data = fn_get_status_data($status_name, $params['type']);
         if ($status_data) {
             $status = Response::STATUS_CREATED;
             $data = array('status_id' => $status_data['status_id']);
         }
     }
     return array('status' => $status, 'data' => $data);
 }
Пример #2
0
 /**
  * Get order data
  */
 public static function getOrderInfo($order_id)
 {
     $object = fn_get_order_info($order_id, false, true, true);
     $object['date'] = fn_twg_format_time($object['timestamp']);
     $status_data = fn_get_status_data($object['status'], STATUSES_ORDER);
     $object['status'] = empty($status_data['description']) ? '' : $status_data['description'];
     $object['items'] = !empty($object['items']) && is_array($object['items']) ? array_values($object['items']) : array();
     $object['shipping'] = array_values(isset($object['shipping']) ? $object['shipping'] : array());
     $object['taxes'] = array_values($object['taxes']);
     $object['items'] = array_values($object['products']);
     unset($object['products']);
     return $object;
 }
Пример #3
0
function fn_gift_certificate_notification(&$gift_cert_data, $force_notification = array())
{
    static $notified = array();
    if (!empty($notified[$gift_cert_data['gift_cert_id']])) {
        return true;
    }
    $status_params = fn_get_status_params($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE);
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    if ($notify_user == true && $gift_cert_data['email'] && $gift_cert_data['send_via'] == 'E') {
        $notified[$gift_cert_data['gift_cert_id']] = true;
        $templates = fn_get_gift_certificate_templates();
        $gift_cert_data['template'] = isset($templates[$gift_cert_data['template']]) ? $gift_cert_data['template'] : key($templates);
        Mailer::sendMail(array('to' => $gift_cert_data['email'], 'from' => 'company_orders_department', 'data' => array('gift_cert_data' => $gift_cert_data, 'certificate_status' => fn_get_status_data($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE, $gift_cert_data['gift_cert_id'])), 'tpl' => 'addons/gift_certificates/gift_certificate.tpl', 'company_id' => $gift_cert_data['company_id']), 'C');
        return true;
    }
    return false;
}
Пример #4
0
function fn_companies_suppliers_order_notification($order_info, $order_statuses, $force_notification)
{
    static $notification_sent = array();
    if (!empty($notification_sent[$order_info['order_id']][$order_info['status']]) && $notification_sent[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) {
        return true;
    }
    $status_params = $order_statuses[$order_info['status']];
    $notify_supplier = isset($force_notification['S']) ? $force_notification['S'] : (!empty($status_params['notify_supplier']) && $status_params['notify_supplier'] == 'Y' ? true : false);
    if ($notify_supplier == true) {
        $notification_sent[$order_info['order_id']][$order_info['status']] = true;
        $suppliers = array();
        foreach ($order_info['items'] as $k => $v) {
            if (isset($v['company_id'])) {
                $suppliers[$v['company_id']] = 0;
            }
        }
        if (!empty($suppliers)) {
            if (!empty($order_info['shipping'])) {
                foreach ($order_info['shipping'] as $shipping_id => $shipping) {
                    foreach ((array) $shipping['rates'] as $supplier_id => $rate) {
                        if (isset($suppliers[$supplier_id])) {
                            $suppliers[$supplier_id] += $rate;
                        }
                    }
                }
            }
            Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.admin_default_language')));
            Registry::get('view_mail')->assign('order_info', $order_info);
            Registry::get('view_mail')->assign('status_inventory', $order_statuses[$order_info['status']]['inventory']);
            foreach ($suppliers as $supplier_id => $shipping_cost) {
                if ($supplier_id != 0) {
                    Registry::get('view_mail')->assign('shipping_cost', $shipping_cost);
                    Registry::get('view_mail')->assign('supplier_id', $supplier_id);
                    $supplier = fn_get_company_data($supplier_id);
                    fn_send_mail($supplier['email'], Registry::get('settings.Company.company_orders_department'), 'orders/supplier_notification_subj.tpl', 'orders/supplier_notification.tpl', '', Registry::get('settings.Appearance.admin_default_language'));
                }
            }
            return true;
        }
    }
    return false;
}
Пример #5
0
function fn_twg_get_order_status($status_type, $order_id)
{
    $status = '';
    $status_info = fn_get_status_data($status_type, STATUSES_ORDER, $order_id, CART_LANGUAGE);
    if (!empty($status_info['description'])) {
        $status = $status_info['description'];
    }
    return $status;
}
Пример #6
0
/**
 * Gets full information about a particular status by identifier
 * @param int $status_id Status identifier
 * @param string $lang_code Language code
 * @return array Status idata
 */
function fn_get_status_by_id($status_id, $lang_code = DESCR_SL)
{
    $status_data = array();
    $status = db_get_row("SELECT status, type FROM ?:statuses WHERE status_id = ?i", $status_id);
    if (!empty($status)) {
        $status_data = fn_get_status_data($status['status'], $status['type'], 0, $lang_code);
    }
    return $status_data;
}
Пример #7
0
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['status'])) {
            if (fn_delete_status($_REQUEST['status'], $_REQUEST['type'])) {
                $count = db_get_field("SELECT COUNT(*) FROM ?:statuses");
                if (empty($count)) {
                    Tygh::$app['view']->display('views/statuses/manage.tpl');
                }
            }
        }
        exit;
    }
    return array(CONTROLLER_STATUS_OK, 'statuses.manage?type=' . $_REQUEST['type']);
}
if ($mode == 'update') {
    $status_data = fn_get_status_data($_REQUEST['status'], $_REQUEST['type']);
    Tygh::$app['view']->assign('status_data', $status_data);
    Tygh::$app['view']->assign('type', $_REQUEST['type']);
    Tygh::$app['view']->assign('status_params', fn_get_status_params_definition($_REQUEST['type']));
} elseif ($mode == 'manage') {
    $section_data = array();
    $statuses = fn_get_statuses($_REQUEST['type'], array(), false, false, DESCR_SL);
    Tygh::$app['view']->assign('statuses', $statuses);
    $type = !empty($_REQUEST['type']) ? $_REQUEST['type'] : STATUSES_ORDER;
    Tygh::$app['view']->assign('type', $type);
    Tygh::$app['view']->assign('status_params', fn_get_status_params_definition($type));
    // Orders only
    if ($type == STATUSES_ORDER) {
        Tygh::$app['view']->assign('title', __('order_statuses'));
    }
}
Пример #8
0
function fn_send_return_mail(&$return_info, &$order_info, $force_notification = array())
{
    $return_statuses = fn_get_statuses(STATUSES_RETURN);
    $status_params = $return_statuses[$return_info['status']];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true) {
        Registry::get('view_mail')->assign('order_info', $order_info);
        Registry::get('view_mail')->assign('return_info', $return_info);
        Registry::get('view_mail')->assign('reasons', fn_get_rma_properties(RMA_REASON));
        Registry::get('view_mail')->assign('actions', fn_get_rma_properties(RMA_ACTION));
        Registry::get('view_mail')->assign('return_status', fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $order_info['lang_code']));
        // Notify customer
        if ($notify_user == true) {
            fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'addons/rma/slip_notification_subj.tpl', 'addons/rma/slip_notification.tpl', '', $order_info['lang_code']);
        }
        // Notify administrator (only if the changes performed from customer area)
        if (AREA == 'C' || $notify_department == true) {
            // Translate descriptions to admin language
            Registry::get('view_mail')->assign('return_status', fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], Registry::get('settings.Appearance.admin_default_language')));
            fn_send_mail(Registry::get('settings.Company.company_orders_department'), Registry::get('settings.Company.company_orders_department'), 'addons/rma/slip_notification_subj.tpl', 'addons/rma/slip_notification.tpl', '', Registry::get('settings.Appearance.admin_default_language'), $order_info['email']);
        }
    }
}
Пример #9
0
function fn_twg_send_order_status_push_notification($order_info, $order_statuses, $force_notification, $connector, $company_id)
{
    $status_params = $order_statuses[$order_info['status']];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    if (!$notify_user || empty($order_info['user_id']) || $order_info['user_id'] == 0) {
        return;
    }
    $stores = fn_twg_get_stores();
    // If it is not a connected platinum store - return
    if (empty($stores[$company_id]['is_connected']) || !$stores[$company_id]['is_platinum']) {
        return;
    }
    // If push notifications are disabled for this store - don't send them
    if (empty($stores[$company_id]['send_order_status_push']) || $stores[$company_id]['send_order_status_push'] != 'Y') {
        return;
    }
    $order_status = fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $order_info['lang_code']);
    $message = fn_twg_get_lang_var('order', $order_info['lang_code']) . ' #' . $order_info['order_id'] . ' ' . $order_status['email_subj'];
    $connector->show_notifications = false;
    $data = array('access_id' => $stores[$company_id]['access_id'], 'user_id' => $order_info['user_id'], 'message' => $message);
    $meta = array('access_id' => $connector->getAccessID('A'));
    $connector->send('order.status_changed', $data, $meta);
}
Пример #10
0
function fn_qwintry_save_order_invoice($order_id, $area = AREA, $lang_code = CART_LANGUAGE)
{
    $view = Tygh::$app['view'];
    $html = array();
    $view->assign('order_status_descr', fn_get_simple_statuses(STATUSES_ORDER, true, true));
    $view->assign('profile_fields', fn_get_profile_fields('I'));
    $order_info = fn_get_order_info($order_id, false, true, false, true);
    if (empty($order_info)) {
        return;
    }
    if (fn_allowed_for('MULTIVENDOR')) {
        $view->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($order_info['products']));
    }
    list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true));
    $use_shipments = !fn_one_full_shipped($shipments);
    $view->assign('order_info', $order_info);
    $view->assign('shipments', $shipments);
    $view->assign('use_shipments', $use_shipments);
    $view->assign('payment_method', fn_get_payment_data(!empty($order_info['payment_method']['payment_id']) ? $order_info['payment_method']['payment_id'] : 0, $order_info['order_id'], $lang_code));
    $view->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $lang_code, $order_info['company_id']));
    $view->assign('status_settings', fn_get_status_params($order_info['status']));
    $view->assign('company_data', fn_get_company_placement_info($order_info['company_id'], $lang_code));
    fn_disable_live_editor_mode();
    $html[] = $view->displayMail('orders/print_invoice.tpl', false, $area, $order_info['company_id'], $lang_code);
    $filename = QWINTRY_DIR_INVOICES . $order_id . '.pdf';
    if (Pdf::render($html, $filename, true)) {
        return $filename;
    }
    return false;
}
Пример #11
0
/**
 * Hook for modify shippings groups
 *
 * @param array $cart Cart array
 * @param array $allow
 * @param array $product_groups Products groups from cart
 */
function fn_suppliers_order_notification(&$order_info, &$order_statuses, &$force_notification)
{
    $status_params = $order_statuses[$order_info['status']]['params'];
    $notify_supplier = isset($force_notification['S']) ? $force_notification['S'] : (!empty($status_params['notify_supplier']) && $status_params['notify_supplier'] == 'Y' ? true : false);
    if ($notify_supplier == true) {
        $suppliers = array();
        if (!empty($order_info['product_groups'])) {
            foreach ($order_info['product_groups'] as $key_group => $group) {
                foreach ($group['products'] as $cart_id => $product) {
                    $supplier_id = fn_get_product_supplier_id($product['product_id']);
                    if (!empty($supplier_id) && empty($suppliers[$supplier_id])) {
                        $rate = 0;
                        foreach ($group['chosen_shippings'] as $shipping) {
                            $rate += $shipping['rate'];
                        }
                        $suppliers[$supplier_id] = array('name' => fn_get_supplier_name($supplier_id), 'company_id' => $group['company_id'], 'cost' => $rate, 'shippings' => $group['chosen_shippings']);
                    }
                    if (!empty($supplier_id)) {
                        $suppliers[$supplier_id]['products'][$cart_id] = $product;
                    }
                }
            }
        }
        foreach ($suppliers as $supplier_id => $supplier) {
            $lang = fn_get_company_language($supplier['company_id']);
            $order = $order_info;
            $order['products'] = $supplier['products'];
            $supplier['data'] = fn_get_supplier_data($supplier_id);
            if (!empty($supplier['shippings'])) {
                if (!empty($supplier['data']['shippings'])) {
                    $shippings = array();
                    foreach ($supplier['shippings'] as $shipping) {
                        if (!isset($shippings[$shipping['group_name']])) {
                            $shippings[$shipping['group_name']] = $shipping;
                        }
                    }
                    foreach ($shippings as $key => $shipping) {
                        if ($key != $supplier['name']) {
                            unset($shippings[$key]);
                            if ($supplier['cost'] > $shipping['rate']) {
                                $supplier['cost'] -= $shipping['rate'];
                            } else {
                                $supplier['cost'] = 0;
                            }
                        }
                    }
                    $supplier['shippings'] = array_values($shippings);
                } else {
                    $supplier['shippings'] = array();
                }
            }
            Mailer::sendMail(array('to' => $supplier['data']['email'], 'from' => 'company_orders_department', 'reply_to' => 'company_orders_department', 'data' => array('order_info' => $order, 'status_inventory' => $status_params['inventory'], 'supplier_id' => $supplier_id, 'supplier' => $supplier, 'order_status' => fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $lang), 'profile_fields' => fn_get_profile_fields('I', '', $lang)), 'tpl' => 'addons/suppliers/notification.tpl'), 'A', $lang);
        }
    }
}
Пример #12
0
/**
 * Send order notification
 *
 * @param array $order_info order information
 * @param array $edp_data information about downloadable products
 * @param mixed $force_notification user notification flag (true/false), if not set, will be retrieved from status parameters
 * @return array structured data
 */
function fn_order_notification(&$order_info, $edp_data = array(), $force_notification = array())
{
    static $notified = array();
    if (!empty($notified[$order_info['order_id']][$order_info['status']]) && $notified[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) {
        return true;
    }
    if (!is_array($force_notification)) {
        $force_notification = fn_get_notification_rules($force_notification, !$force_notification);
    }
    $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true);
    $status_params = $order_statuses[$order_info['status']];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true) {
        $notified[$order_info['order_id']][$order_info['status']] = true;
        Registry::get('view_mail')->assign('order_info', $order_info);
        Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $order_info['lang_code']));
        Registry::get('view_mail')->assign('status_settings', $order_statuses[$order_info['status']]);
        $companies =& Registry::get('s_companies');
        Registry::get('view_mail')->assign('companies', $companies);
        // restore secondary currency
        if (!empty($order_info['secondary_currency']) && Registry::get("currencies.{$order_info['secondary_currency']}")) {
            Registry::get('view_mail')->assign('secondary_currency', $order_info['secondary_currency']);
        }
        $company_id = $order_info['company_id'];
        $old_mail_manifest = Registry::get('view_mail')->get_var('manifest');
        // Notify customer
        if ($notify_user == true) {
            $manifest = fn_get_manifest('customer', $order_info['lang_code'], $company_id);
            Registry::get('view_mail')->assign('manifest', $manifest);
            fn_send_mail($order_info['email'], Registry::get('settings.Company.company_newsletter_email'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $order_info['lang_code']);
            //		fn_send_mail('*****@*****.**', Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $order_info['lang_code']);
        }
        if ($notify_department == true) {
            // Translate descriptions to admin language
            fn_translate_products($order_info['items'], 'product', Registry::get('settings.Appearance.admin_default_language'));
            Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.admin_default_language')));
            $company_email = !empty($companies[$company_id]['email']) ? $companies[$company_id]['email'] : Registry::get('settings.Company.company_orders_department');
            $lang_code = Registry::get('settings.Appearance.admin_default_language');
            $manifest = fn_get_manifest('customer', $lang_code, $company_id);
            Registry::get('view_mail')->assign('manifest', $manifest);
            fn_send_mail($company_email, Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $lang_code, $order_info['email']);
            if (Registry::get('settings.Suppliers.notify_order_department') == 'Y') {
                Registry::get('view_mail')->assign('manifest', $old_mail_manifest);
                fn_send_mail(Registry::get('settings.Company.company_orders_department'), Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $lang_code, $order_info['email']);
            }
        }
        Registry::get('view_mail')->assign('manifest', $old_mail_manifest);
        if (!empty($edp_data) && $notify_user == true) {
            Registry::get('view_mail')->assign('edp_data', $edp_data);
            fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'orders/edp_access_subj.tpl', 'orders/edp_access.tpl', '', $order_info['lang_code']);
        }
    }
    if (!empty($edp_data) && !$notify_user) {
        // Send out download links for EDP with "Immediately" Activation mode
        // TRUE if the EDP download links e-mail has already been sent. Used to avoid sending duplicate e-mails.
        $download_email_sent = false;
        foreach ($edp_data as $edp_item) {
            foreach ($edp_item['files'] as $file) {
                if (!empty($file['activation']) && $file['activation'] == 'I' && !$download_email_sent) {
                    Registry::get('view_mail')->assign('edp_data', $edp_data);
                    Registry::get('view_mail')->assign('order_info', $order_info);
                    fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'orders/edp_access_subj.tpl', 'orders/edp_access.tpl', '', $order_info['lang_code']);
                    $download_email_sent = true;
                    break;
                }
            }
        }
    }
    if (PRODUCT_TYPE == 'PROFESSIONAL') {
        fn_companies_suppliers_order_notification($order_info, $order_statuses, $force_notification);
    }
    fn_set_hook('order_notification', $order_info, $order_statuses, $force_notification);
}
Пример #13
0
function fn_rus_unisender_send_sms($text_sms, $phone, $order_id = 0, $status_to = '', $notify = true)
{
    if (!empty($phone)) {
        $post = array('api_key' => Registry::get('addons.rus_unisender.api_key'), 'sender' => fn_substr(Registry::get('addons.rus_unisender.sender'), 0, 11), 'phone' => fn_unisender_format_phone($phone));
        $send_sms = false;
        if ($order_id == 0) {
            $post['text'] = $text_sms;
            $send_sms = true;
        } else {
            $statuses = Registry::get('addons.rus_unisender.order_status_sms');
            if (array_key_exists($status_to, $statuses)) {
                $status_data = fn_get_status_data($status_to, STATUSES_ORDER);
                $status_description = $status_data['description'];
                $text = str_replace('[status]', $status_description, $text_sms);
                $post['text'] = $text;
                $send_sms = true;
            }
        }
        if ($send_sms) {
            if (!fn_unisender_api('sendSms', $post, $response)) {
                if (AREA == 'C') {
                    $email = Registry::get('settings.Company.company_site_administrator');
                    Mailer::sendMail(array('to' => $email, 'from' => 'company_site_administrator', 'data' => array('phone' => $phone, 'error' => $response), 'tpl' => 'addons/rus_unisender/unisender.tpl', 'company_id' => fn_get_company_id('orders', 'order_id', $order_id)), 'C', CART_LANGUAGE);
                }
            } elseif (AREA != 'C') {
                fn_set_notification('N', __('notice'), __('sent'));
            }
        }
    }
    return false;
}
Пример #14
0
 /**
  * Get order data
  */
 public static function getOrderInfo($order_id)
 {
     $object = fn_get_order_info($order_id, false, true, true);
     $object['date'] = fn_twg_format_time($object['timestamp']);
     $status_data = fn_get_status_data($object['status'], STATUSES_ORDER);
     if (AREA == 'C') {
         $object['status'] = empty($status_data['description']) ? '' : $status_data['description'];
     }
     $object['shipping'] = array_values(isset($object['shipping']) ? $object['shipping'] : array());
     $object['taxes'] = array_values($object['taxes']);
     $object['items'] = self::setProductsPointsInfo(array('products' => array_values($object['products'])));
     unset($object['products']);
     foreach ($object['items'] as &$product) {
         if (!empty($product['extra']['points_info']) && Registry::get('addons.reward_points.status') != 'A') {
             unset($product['extra']['points_info']);
         }
     }
     if (Registry::get('settings.General.use_shipments') == 'Y') {
         $shipments = db_get_array('SELECT ?:shipments.shipment_id, ?:shipments.comments, ?:shipments.tracking_number, ?:shipping_descriptions.shipping AS shipping, ?:shipments.carrier FROM ?:shipments LEFT JOIN ?:shipment_items ON (?:shipments.shipment_id = ?:shipment_items.shipment_id) LEFT JOIN ?:shipping_descriptions ON (?:shipments.shipping_id = ?:shipping_descriptions.shipping_id) WHERE ?:shipment_items.order_id = ?i AND ?:shipping_descriptions.lang_code = ?s GROUP BY ?:shipments.shipment_id', $order_id, DESCR_SL);
         if (!empty($shipments)) {
             foreach ($shipments as $id => $shipment) {
                 $shipments[$id]['items'] = db_get_array('SELECT item_id, amount FROM ?:shipment_items WHERE shipment_id = ?i', $shipment['shipment_id']);
             }
         }
         $object['shipments'] = $shipments;
     }
     return $object;
 }
Пример #15
0
function fn_print_order_invoices($order_ids, $pdf = false, $area = AREA, $lang_code = CART_LANGUAGE)
{
    $view = Registry::get('view');
    $html = array();
    $view->assign('order_status_descr', fn_get_simple_statuses(STATUSES_ORDER, true, true));
    $view->assign('profile_fields', fn_get_profile_fields('I'));
    if (!is_array($order_ids)) {
        $order_ids = array($order_ids);
    }
    foreach ($order_ids as $order_id) {
        $order_info = fn_get_order_info($order_id, false, true, false, true);
        if (empty($order_info)) {
            continue;
        }
        if (fn_allowed_for('MULTIVENDOR')) {
            $view->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($order_info['products']));
        }
        list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true));
        $use_shipments = !fn_one_full_shipped($shipments);
        $view->assign('order_info', $order_info);
        $view->assign('shipments', $shipments);
        $view->assign('use_shipments', $use_shipments);
        $view->assign('payment_method', fn_get_payment_data(!empty($order_info['payment_method']['payment_id']) ? $order_info['payment_method']['payment_id'] : 0, $order_info['order_id'], $lang_code));
        $view->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $lang_code, $order_info['company_id']));
        $view->assign('status_settings', fn_get_status_params($order_info['status']));
        $view->assign('company_data', fn_get_company_placement_info($order_info['company_id'], $lang_code));
        if ($pdf == true) {
            fn_disable_live_editor_mode();
            $html[] = $view->displayMail('orders/print_invoice.tpl', false, $area, $order_info['company_id'], $lang_code);
        } else {
            $view->displayMail('orders/print_invoice.tpl', true, $area, $order_info['company_id'], $lang_code);
            if ($order_id != end($order_ids)) {
                echo "<div style='page-break-before: always;'>&nbsp;</div>";
            }
        }
    }
    if ($pdf == true) {
        Pdf::render($html, __('invoices') . '-' . implode('-', $order_ids));
    }
    return true;
}
Пример #16
0
function fn_send_return_mail(&$return_info, &$order_info, $force_notification = array())
{
    $return_statuses = fn_get_statuses(STATUSES_RETURN);
    $status_params = $return_statuses[$return_info['status']]['params'];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    $notify_vendor = isset($force_notification['V']) ? $force_notification['V'] : (!empty($status_params['notify_vendor']) && $status_params['notify_vendor'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true || $notify_vendor == true) {
        $rma_reasons = fn_get_rma_properties(RMA_REASON);
        $rma_actions = fn_get_rma_properties(RMA_ACTION);
        // Notify customer
        if ($notify_user == true) {
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $order_info['lang_code'])), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
        }
        if ($notify_vendor == true) {
            if (fn_allowed_for('MULTIVENDOR') && !empty($order_info['company_id'])) {
                $company_language = fn_get_company_language($order_info['company_id']);
                Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $company_language)), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'A', $company_language);
            }
        }
        // Notify administrator (only if the changes performed from the frontend)
        if ($notify_department == true) {
            Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => Registry::get('settings.Company.company_orders_department'), 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], Registry::get('settings.Appearance.backend_default_language'))), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language'));
        }
    }
}
Пример #17
0
function fn_gift_certificate_notification(&$gift_cert_data, $force_notification = array())
{
    static $notified = array();
    if (!empty($notified[$gift_cert_data['gift_cert_id']])) {
        return true;
    }
    $status_params = fn_get_status_params($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE);
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    if ($notify_user == true && $gift_cert_data['email'] && $gift_cert_data['send_via'] == 'E') {
        $notified[$gift_cert_data['gift_cert_id']] = true;
        $templates = fn_get_gift_certificate_templates();
        $gift_cert_data['template'] = isset($templates[$gift_cert_data['template']]) ? $gift_cert_data['template'] : key($templates);
        Registry::get('view_mail')->assign('gift_cert_data', $gift_cert_data);
        Registry::get('view_mail')->assign('certificate_status', fn_get_status_data($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE, $gift_cert_data['gift_cert_id']));
        fn_send_mail($gift_cert_data['email'], Registry::get('settings.Company.company_orders_department'), 'addons/gift_certificates/gift_certificate_subj.tpl', 'addons/gift_certificates/gift_certificate.tpl');
        return true;
    }
    return false;
}