function cw_cron_invoice_check_params($time, $prev_time) { global $tables, $config, $smarty; $expired_invoices = array(); $notify_invoices = array(); $days_notify = intval($config['General']['days_notify_expiration_invoice']); $result = cw_query("SELECT d.doc_id, d.display_id, ui.customer_id, di.expiration_date\n\t\t\t\t\t\t\tFROM {$tables['docs']} d\n\t\t\t\t\t\t\tLEFT JOIN {$tables['docs_info']} di ON di.doc_info_id = d.doc_info_id\n\t\t\t\t\t\t\tLEFT JOIN {$tables['docs_user_info']} ui ON ui.doc_info_id = d.doc_info_id\n\t\t\t\t\t\t\tWHERE di.expiration_date <> 0 AND d.type = 'I' AND status <> 'C' AND status <> 'F'"); if (!empty($result)) { foreach ($result as $value) { if (!empty($value['customer_id'])) { $expiration_date = $value['expiration_date']; $days_left = floor(($expiration_date - $time) / SECONDS_PER_DAY); // invoice is expired if ($days_left <= 0) { cw_load('mail', 'doc'); $doc_id = $value['doc_id']; $status = 'F'; $expired_invoices[] = "ID:" . $doc_id . " NUMBER:" . $value['display_id']; cw_call('cw_doc_change_status', array($doc_id, $status)); } elseif ($days_notify > 0 && $days_left == $days_notify) { cw_load('mail', 'doc', 'web'); $doc_id = $value['doc_id']; $doc_data = cw_call('cw_doc_get', array($doc_id, 8192)); $notify_invoices[] = "ID:" . $doc_id . " NUMBER:" . $value['display_id']; if (empty($doc_data)) { continue; } if ($doc_data['info']['layout_id']) { $layout = cw_web_get_layout_by_id($doc_data['info']['layout_id']); } else { $layout = cw_web_get_layout('docs_' . $doc_data['type']); } $smarty->assign('layout_data', $layout); $smarty->assign('info', $doc_data['info']); $smarty->assign('products', $doc_data['products']); $smarty->assign('order', $doc_data); $smarty->assign('doc', $doc_data); cw_call('cw_send_mail', array($config['Company']['orders_department'], $doc_data['userinfo']['email'], 'mail/docs/customer_subj.tpl', 'mail/docs/customer.tpl', null, false, true)); } } } } $message = ""; if (count($expired_invoices)) { $message = "\n Expired invoices: '" . implode(", ", $expired_invoices) . "'"; } if (count($notify_invoices)) { $message .= "\n Notify invoices: '" . implode(", ", $notify_invoices) . "'"; } return $message; }
$smarty->assign('customer', $doc_data['userinfo']); $mem_usertype = $aom_orders[$doc_id]['userinfo']['usertype']; $smarty->assign('memberships', cw_user_get_memberships($mem_usertype)); if ($real_taxes == "Y") { global $current_area, $customer_id, $user_account; $_saved_data = compact("current_area", "customer_id", "user_account"); $current_area = $current_area == 'G' ? 'G' : 'C'; $customer_id = $aom_orders[$doc_id]['userinfo']['customer_id']; $user_account = $aom_orders[$doc_id]['userinfo']; } $smarty->assign('payment_methods', cw_func_call('cw_payment_search', array('data' => array('type' => 1)))); //$smarty->assign('shipping', cw_func_call('cw_shipping_search', array('data' => array('active' => 1)))); //$smarty->assign('salesmen', cw_user_get_salesmans_for_register()); $smarty->assign('cod_types', cw_shipping_get_shipping_cod_types($aom_orders[$doc_id]['info']['shipping_id'])); $config['Appearance']['allow_update_quantity_in_cart'] = "N"; $smarty->assign('default_use_only_ean', 'Y'); $smarty->assign('order', $aom_orders[$doc_id]); $smarty->assign('orig_order', $doc_data); if ($doc_data['info']['layout_id']) { $smarty->assign('layout_data', cw_web_get_layout_by_id($doc_data['info']['layout_id'])); } else { $smarty->assign('layout_data', cw_web_get_layout('docs_' . $docs_type)); } $coupons = cw_query("select * from {$tables['discount_coupons']} where coupon_type != 'free_ship' ORDER BY coupon"); $coupon_exists = cw_query_first_cell("select count(*) from {$tables['discount_coupons']} WHERE coupon = '" . addslashes($aom_orders[$doc_id]['coupon']) . "'") > 0 ? "Y" : ""; if (!empty($coupons)) { $smarty->assign('coupons', $coupons); } $smarty->assign('coupon_exists', $coupon_exists); $smarty->assign('js_tab', $js_tab); $smarty->assign('main', 'order_edit');
} else { $error_message = cw_get_langvar_by_name('txt_aom_total_is_incorrect'); } } if (!$aom_orders[$doc_id]['saved']) { $smarty->assign('reset_error', 1); } $smarty->assign('update_time', cw_core_get_time()); if (count($not_found)) { $error_message .= cw_get_langvar_by_name('txt_aom_product_eans_not_found') . implode('<br/>', $not_found) . '<br/>'; } if (count($out_products)) { foreach ($out_products as $pr) { if ($pr[0] == 1) { $error_message .= cw_get_langvar_by_name('txt_aom_products_out_of_stock') . ' ' . $pr[1] . '<br/>'; } elseif ($pr[0] == 2) { $error_message .= cw_get_langvar_by_name('txt_aom_products_not_added') . ' ' . $pr[1] . '<br/>'; } elseif ($pr[0] == 3) { $error_message .= cw_get_langvar_by_name('txt_aom_choose_supplier') . ' ' . $pr[1] . '<br/>'; } } } $smarty->assign('errors', $error_message); $smarty->assign('doc_id', $doc_id); $smarty->assign('doc', $aom_orders[$doc_id]); $smarty->assign('product_layout_elements', cw_call('cw_web_get_product_layout_elements')); $smarty->assign('layout_data', cw_web_get_layout('docs_' . $aom_orders[$doc_id]['type'][0])); //$smarty->assign('debug_data', print_r($dd, true)); cw_include("addons/shipping_system/include/orders/order_edit.php"); $result = cw_display('addons/advanced_order_management/order_info_ajax.tpl', $smarty, FALSE); exit($result);
function cw_doc_print($doc_data, $mode) { global $smarty, $current_area, $app_skins_dirs; cw_load('web'); if ($doc_data['info']['layout_id']) { $layout = cw_web_get_layout_by_id($doc_data['info']['layout_id']); } else { $layout = cw_web_get_layout('docs_' . $doc_data['type']); } $smarty->assign('layout_data', $layout); $smarty->assign('doc', $doc_data); $smarty->assign('current_section', ''); $smarty->assign('main', 'order_print'); $smarty->assign('home_style', 'iframe'); $smarty->assign('is_printing', true); if ($mode == 'print') { cw_display($app_skins_dirs[$current_area] . '/index.tpl', $smarty); } elseif ($mode == 'print_pdf' || ($mode = 'print_aom_pdf')) { cw_load('pdf'); cw_pdf_generate(cw_get_langvar_by_name('lbl_doc_info_' . $doc_data['type'], false, false, true), $app_skins_dirs[$current_area] . '/index.tpl'); } }
<?php if ($REQUEST_METHOD == 'POST' && $mode == "order_messages") { $top_message =& cw_session_register('top_message'); if ($action == "new_thread") { //start new thread and place new message if (!empty($new_thread['standard_email'])) { $status = $new_thread['standard_email']; $doc_data = cw_call('cw_doc_get', array($doc_id, 8192)); //trigger email and register it in messages cw_load('web'); if ($doc_data['info']['layout_id']) { $layout = cw_web_get_layout_by_id($doc_data['info']['layout_id']); } else { $layout = cw_web_get_layout('docs_' . $doc_data['type']); } $smarty->assign('layout_data', $layout); $smarty->assign('info', $doc_data['info']); $smarty->assign('products', $doc_data['products']); $smarty->assign('order', $doc_data); $smarty->assign('doc', $doc_data); $to_customer = cw_query_first_cell("SELECT language FROM {$tables['customers']} WHERE customer_id='{$doc_data['userinfo']}[customer_id]'"); if (empty($to_customer)) { $to_customer = $config['default_customer_language']; } $doc_data['products'] = cw_doc_translate_products($doc_data['products'], $to_customer); $smarty->assign('order', $doc_data); cw_call('cw_send_mail', array($config['order_messages']['contact_email_address'], $doc_data['userinfo']['email'], 'mail/docs/customer_subj.tpl', 'mail/docs/customer.tpl', $to_customer, false, true)); } else { $new_thread_id = cw_array2insert('order_messages_threads', array('doc_id' => $doc_id, 'type' => !empty($new_thread['standard_email']) ? 'A' : 'M')); if ($new_thread_id) {