function fn_print_shipment_packing_slips($shipment_ids, $pdf = false, $lang_code = CART_LANGUAGE) { $view = Tygh::$app['view']; $month = array(1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря'); foreach ($shipment_ids as $shipment_id) { list($shipment, $order_info) = fn_get_packing_info($shipment_id); $order_info_ = fn_get_order_info($order_info['order_id']); if (empty($shipment)) { continue; } $total_weight = 0; // foreach($order_info['products'] as $pi=>$pv) // { // $total_weight+=$pv['weight']; // } $order_info['payment_info'] = $order_info_['payment_info']; $order_info['payment_method'] = $order_info_['payment_method']; $order_info['timestamp'] = $order_info_['timestamp']; $order_info['info_customer'] = ""; $n_month = (int) date("m", $order_info['timestamp']); $invoice_date = date("d", $order_info['timestamp']) . ' ' . $month[$n_month] . ' ' . date("Y", $order_info['timestamp']); $order_info['text_invoice_payment'] = __("addons.rus_payments.text_invoice_payment", array('[number_account]' => $order_info['order_id'], '[invoice_data]' => $invoice_date)); $order_info['invoice_date'] = $invoice_date; $products = fn_load_products_extra_data($order_info['products'], array('only_short_fields' => true), 'ru'); $total_amount = 0; //var_dump($products); die(); foreach ($products as $pi => $pv) { $weights[$pi] = $pv['weight']; $total_weight += $pv['weight'] * $pv['shipped_amount']; $total_amount += $pv['shipped_amount']; //var_dump($pv['amount'],'<br/>'); } $order_info['weights'] = $weights; $order_info['total_cnt'] = $total_amount; $order_info['str_count'] = RusInvoicePayment::clearDoit($total_amount); $order_info['str_count'] = str_replace('Один', 'Одно', $order_info['str_count']); $order_info['str_count'] = str_replace(array(' 00 копеек', 'рублей', 'рубль', 'рубля'), '', $order_info['str_count']); $order_info['total_weight'] = RusInvoicePayment::clearDoit($total_weight); $order_info['total_weight'] = str_replace(array('рублей', 'рубль'), 'килограмм', $order_info['total_weight']); $order_info['total_weight'] = str_replace('рубля', 'килограмма', $order_info['total_weight']); $order_info['total_weight'] = str_replace('копеек', 'грамм', $order_info['total_weight']); $order_info['str_total'] = RusInvoicePayment::clearDoit($order_info['display_subtotal']); if (!empty($order_info['payment_info'])) { if (!empty($order_info['payment_info']['organization_customer'])) { $order_info['info_customer'] .= $order_info['payment_info']['organization_customer'] . ' '; } if (!empty($order_info['payment_info']['inn_customer'])) { $order_info['info_customer'] .= __("inn_customer") . ': ' . $order_info['payment_info']['inn_customer'] . ' '; } if (!empty($order_info['payment_info']['kpp_customer'])) { $order_info['info_customer'] .= __("kpp_customer") . ': ' . $order_info['payment_info']['kpp_customer'] . ' '; } if (!empty($order_info['payment_info']['ogrn_customer'])) { $order_info['info_customer'] .= __("ogrn_customer") . ': ' . $order_info['payment_info']['ogrn_customer'] . ' '; } if (!empty($order_info['payment_info']['phone'])) { $order_info['info_customer'] .= __("phone") . ': ' . $order_info['payment_info']['phone'] . ' '; } if (!empty($order_info['payment_info']['zip_postal_code'])) { $order_info['info_customer'] .= __("zip_postal_code") . ': ' . $order_info['payment_info']['zip_postal_code'] . ' '; } if (!empty($order_info['payment_info']['address'])) { $order_info['info_customer'] .= __("address") . ': ' . $order_info['payment_info']['address'] . ' '; } if (!empty($order_info['payment_info']['bank_details'])) { $order_info['info_customer'] .= __("addons.rus_payments.bank_details") . ': ' . $order_info['payment_info']['bank_details']; } } $order_info['info_supplier'] = ""; $data_payment = $order_info['payment_method']['processor_params']; if (!empty($data_payment)) { if (!empty($data_payment['account_recepient_name'])) { $order_info['info_supplier'] .= $data_payment['account_recepient_name'] . '; '; } if (!empty($data_payment['account_address'])) { $order_info['info_supplier'] .= __("address") . ': ' . $data_payment['account_address'] . '; '; } if (!empty($data_payment['account_inn'])) { $order_info['info_supplier'] .= __("inn_customer") . ': ' . $data_payment['account_inn'] . ' / '; } if (!empty($data_payment['account_kpp'])) { $order_info['info_supplier'] .= __("addons.rus_payments.account_kpp") . ': ' . $data_payment['account_kpp'] . '; '; } if (!empty($data_payment['account_ogrn'])) { $order_info['info_supplier'] .= __("ogrn_customer") . ': ' . $data_payment['account_ogrn'] . '; '; } if (!empty($data_payment['account_bank'])) { $order_info['info_supplier'] .= "Банк" . ': ' . $data_payment['account_bank'] . ' '; } if (!empty($data_payment['account_current'])) { $order_info['info_supplier'] .= "р/с" . ': ' . $data_payment['account_current'] . '; '; } if (!empty($data_payment['account_cor'])) { $order_info['info_supplier'] .= "к/с" . ': ' . $data_payment['account_cor'] . '; '; } if (!empty($data_payment['account_bik'])) { $order_info['info_supplier'] .= "БИК" . ': ' . $data_payment['account_bik'] . '; '; } // if (!empty($data_payment['account_phone'])) { // $order_info['info_supplier'] .= __("phone") . ': ' . $data_payment['account_phone'] . ' '; // } } $view->assign('order_info', $order_info); $view->assign('shipment', $shipment); if ($pdf == true) { fn_disable_live_editor_mode(); $html[] = $view->displayMail('orders/print_packing_slip.tpl', false, 'A', $order_info['company_id'], $lang_code); } else { $view->displayMail('orders/print_packing_slip.tpl', true, 'A', $order_info['company_id'], $lang_code); if ($shipment_id != end($shipment_ids)) { echo "<div style='page-break-before: always;'> </div>"; } } } if ($pdf == true) { Pdf::render($html, __('shipments') . '-' . implode('-', $shipment_ids)); } return true; }
$view->assign('shipment', $shipment); } fn_add_breadcrumb(fn_get_lang_var('shipments'), 'shipments.manage.reset_view'); fn_add_breadcrumb(fn_get_lang_var('search_results'), "shipments.manage.last_view"); $view->assign('shippings', $shippings); $view->assign('order_info', $order_info); } elseif ($mode == 'manage') { list($shipments, $search, $totals) = fn_get_shipments_info($params); $view->assign('shipments', $shipments); $view->assign('search', $search); $view->assign('totals', $totals); } elseif ($mode == 'packing_slip' && !empty($_REQUEST['shipment_ids'])) { $html = array(); $params = $_REQUEST; foreach ($params['shipment_ids'] as $k => $v) { list($shipment, $order_info) = fn_get_packing_info($v); $view_mail->assign('order_info', $order_info); $view_mail->assign('shipment', $shipment); if (DISPATCH_EXTRA == 'pdf') { $html[] = $view_mail->display('orders/print_packing_slip.tpl', false); } else { $view_mail->display('orders/print_packing_slip.tpl'); echo "<div style='page-break-before: always;'> </div>"; } } exit; } elseif ($mode == 'delete' && !empty($_REQUEST['shipment_ids']) && is_array($_REQUEST['shipment_ids'])) { $shipment_ids = implode(',', $_REQUEST['shipment_ids']); db_query('DELETE FROM ?:shipments WHERE shipment_id IN (?a)', $shipment_ids); db_query('DELETE FROM ?:shipment_items WHERE shipment_id IN (?a)', $shipment_ids); return array(CONTROLLER_STATUS_OK, 'shipments.manage');
function fn_print_shipment_packing_slips($shipment_ids, $pdf = false, $lang_code = CART_LANGUAGE) { $view = Tygh::$app['view']; foreach ($shipment_ids as $shipment_id) { list($shipment, $order_info) = fn_get_packing_info($shipment_id); if (empty($shipment)) { continue; } $view->assign('order_info', $order_info); $view->assign('shipment', $shipment); if ($pdf == true) { fn_disable_live_editor_mode(); $html[] = $view->displayMail('orders/print_packing_slip.tpl', false, 'A', $order_info['company_id'], $lang_code); } else { $view->displayMail('orders/print_packing_slip.tpl', true, 'A', $order_info['company_id'], $lang_code); if ($shipment_id != end($shipment_ids)) { echo "<div style='page-break-before: always;'> </div>"; } } } if ($pdf == true) { Pdf::render($html, __('shipments') . '-' . implode('-', $shipment_ids)); } return true; }