public static function orderReturn($orderReturn, $mode = 'D', $multiple = false, &$pdf = NULL) { $pdf = new PDF('P', 'mm', 'A4'); self::$orderReturn = $orderReturn; $order = new Order($orderReturn->id_order); self::$order = $order; $pdf->SetAutoPageBreak(true, 35); $pdf->StartPageGroup(); $pdf->AliasNbPages(); $pdf->AddPage(); /* Display address information */ $arrayConf = array('PS_SHOP_NAME', 'PS_SHOP_ADDR1', 'PS_SHOP_ADDR2', 'PS_SHOP_CODE', 'PS_SHOP_CITY', 'PS_SHOP_COUNTRY', 'PS_SHOP_DETAILS', 'PS_SHOP_PHONE', 'PS_SHOP_STATE'); $conf = Configuration::getMultiple($arrayConf); foreach ($conf as $key => $value) { $conf[$key] = Tools::iconv('utf-8', self::encoding(), $value); } foreach ($arrayConf as $key) { if (!isset($conf[$key])) { $conf[$key] = ''; } } $width = 100; $pdf->SetX(10); $pdf->SetY(25); $pdf->SetFont(self::fontname(), '', 9); $addressType = array('invoice' => array(), 'delivery' => array()); $patternRules = array('avoid' => array('address2', 'company', 'phone', 'phone_mobile')); $addressType = self::generateHeaderAddresses($pdf, $order, $addressType, $patternRules, $width); /* * display order information */ $pdf->Ln(12); $pdf->SetFillColor(240, 240, 240); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont(self::fontname(), '', 9); $pdf->Cell(0, 6, self::l('RETURN #') . sprintf('%06d', self::$orderReturn->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderReturn->date_upd, self::$order->id_lang), 1, 2, 'L'); $pdf->Cell(0, 6, self::l('We have logged your return request.'), 'TRL', 2, 'L'); $pdf->Cell(0, 6, self::l('Your package must be returned to us within') . ' ' . Configuration::get('PS_ORDER_RETURN_NB_DAYS') . ' ' . self::l('days of receiving your order.'), 'BRL', 2, 'L'); $pdf->Ln(5); $pdf->Cell(0, 6, self::l('List of items marked as returned :'), 0, 2, 'L'); $pdf->Ln(5); $pdf->ProdReturnTab(); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 10); $pdf->Cell(0, 6, self::l('Return reference:') . ' ' . self::l('RET') . sprintf('%06d', self::$order->id), 0, 2, 'C'); $pdf->Cell(0, 6, self::l('Please include this number on your return package.'), 0, 2, 'C'); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 9); $pdf->Cell(0, 6, self::l('REMINDER:'), 0, 2, 'L'); $pdf->SetFont(self::fontname(), '', 9); $pdf->Cell(0, 6, self::l('- All products must be returned in their original packaging without damage or wear.'), 0, 2, 'L'); $pdf->Cell(0, 6, self::l('- Please print out this document and slip it into your package.'), 0, 2, 'L'); $pdf->Cell(0, 6, self::l('- The package should be sent to the following address:'), 0, 2, 'L'); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 10); $pdf->Cell(0, 5, Tools::strtoupper($conf['PS_SHOP_NAME']), 0, 1, 'C', 1); $pdf->Cell(0, 5, !empty($conf['PS_SHOP_ADDR1']) ? self::l('Headquarters:') . ' ' . $conf['PS_SHOP_ADDR1'] . (!empty($conf['PS_SHOP_ADDR2']) ? ' ' . $conf['PS_SHOP_ADDR2'] : '') . ' ' . $conf['PS_SHOP_CODE'] . ' ' . $conf['PS_SHOP_CITY'] . ' ' . $conf['PS_SHOP_COUNTRY'] . ((isset($conf['PS_SHOP_STATE']) and !empty($conf['PS_SHOP_STATE'])) ? ', ' . $conf['PS_SHOP_STATE'] : '') : '', 0, 1, 'C', 1); $pdf->Ln(5); $pdf->SetFont(self::fontname(), '', 9); $pdf->Cell(0, 6, self::l('Upon receiving your package, we will notify you by e-mail. We will then begin processing the reimbursement of your order total.'), 0, 2, 'L'); $pdf->Cell(0, 6, self::l('Let us know if you have any questions.'), 0, 2, 'L'); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 10); $pdf->Cell(0, 6, self::l('If the conditions of return listed above are not respected,'), 'TRL', 2, 'C'); $pdf->Cell(0, 6, self::l('we reserve the right to refuse your package and/or reimbursement.'), 'BRL', 2, 'C'); return $pdf->Output(sprintf('%06d', self::$order->id) . '.pdf', $mode); }
public static function orderReturn($orderReturn, $mode = 'D', $multiple = false, &$pdf = NULL) { $pdf = new PDF('P', 'mm', 'A4'); self::$orderReturn = $orderReturn; $order = new Order($orderReturn->id_order); self::$order = $order; $pdf->SetAutoPageBreak(true, 35); $pdf->StartPageGroup(); $pdf->AliasNbPages(); $pdf->AddPage(); /* Display address information */ $delivery_address = new Address((int) $order->id_address_delivery); $deliveryState = $delivery_address->id_state ? new State($delivery_address->id_state) : false; $arrayConf = array('PS_SHOP_NAME', 'PS_SHOP_ADDR1', 'PS_SHOP_ADDR2', 'PS_SHOP_CODE', 'PS_SHOP_CITY', 'PS_SHOP_COUNTRY', 'PS_SHOP_DETAILS', 'PS_SHOP_PHONE', 'PS_SHOP_STATE'); $conf = Configuration::getMultiple($arrayConf); foreach ($conf as $key => $value) { $conf[$key] = Tools::iconv('utf-8', self::encoding(), $value); } foreach ($arrayConf as $key) { if (!isset($conf[$key])) { $conf[$key] = ''; } } $width = 100; $pdf->SetX(10); $pdf->SetY(25); $pdf->SetFont(self::fontname(), '', 9); $ordered_adr_fields = AddressFormat::getOrderedAddressFields($invoice_address->id_country); $optional_fields = array('address2' => 1, 'company' => 1); $ignore_fields = array('phone' => 1, 'mobile_phone' => 1); foreach ($ordered_adr_fields as $adr_line) { $line_fields = explode(" ", trim($adr_line)); $tmp_dlv_vals = array(); foreach ($line_fields as $field_name) { // if not skip if (!isset($ignore_fields[$field_name])) { $tmp_dlv = $delivery_address->{$field_name}; if (!((empty($tmp_dlv) || $tmp_dlv == '') && isset($optional_fields[$field_name]))) { $tmp_dlv = $field_name == "country" ? $tmp_dlv . ($deliveryState ? ' - ' . $deliveryState->name : '') : $tmp_dlv; $tmp_dlv_vals[] = Tools::iconv('utf-8', self::encoding(), $tmp_dlv); } } } $str_dlv_vals = implode(" ", $tmp_dlv_vals); $need_nl = false; if (!empty($str_dlv_vals) && $str_dlv_vals != '' && $str_dlv_vals != ' ') { $need_nl = true; $pdf->Cell($width, 10, $str_dlv_vals, 0, 'L'); } if ($need_nl) { $pdf->Ln(5); } } /* * display order information */ $pdf->Ln(12); $pdf->SetFillColor(240, 240, 240); $pdf->SetTextColor(0, 0, 0); $pdf->SetFont(self::fontname(), '', 9); $pdf->Cell(0, 6, self::l('RETURN #') . sprintf('%06d', self::$orderReturn->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderReturn->date_upd, self::$order->id_lang), 1, 2, 'L'); $pdf->Cell(0, 6, self::l('We have logged your return request.'), 'TRL', 2, 'L'); $pdf->Cell(0, 6, self::l('Your package must be returned to us within') . ' ' . Configuration::get('PS_ORDER_RETURN_NB_DAYS') . ' ' . self::l('days of receiving your order.'), 'BRL', 2, 'L'); $pdf->Ln(5); $pdf->Cell(0, 6, self::l('List of items marked as returned :'), 0, 2, 'L'); $pdf->Ln(5); $pdf->ProdReturnTab(); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 10); $pdf->Cell(0, 6, self::l('Return reference:') . ' ' . self::l('RET') . sprintf('%06d', self::$order->id), 0, 2, 'C'); $pdf->Cell(0, 6, self::l('Please include this number on your return package.'), 0, 2, 'C'); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 9); $pdf->Cell(0, 6, self::l('REMINDER:'), 0, 2, 'L'); $pdf->SetFont(self::fontname(), '', 9); $pdf->Cell(0, 6, self::l('- All products must be returned in their original packaging without damage or wear.'), 0, 2, 'L'); $pdf->Cell(0, 6, self::l('- Please print out this document and slip it into your package.'), 0, 2, 'L'); $pdf->Cell(0, 6, self::l('- The package should be sent to the following address:'), 0, 2, 'L'); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 10); $pdf->Cell(0, 5, Tools::strtoupper($conf['PS_SHOP_NAME']), 0, 1, 'C', 1); $pdf->Cell(0, 5, !empty($conf['PS_SHOP_ADDR1']) ? self::l('Headquarters:') . ' ' . $conf['PS_SHOP_ADDR1'] . (!empty($conf['PS_SHOP_ADDR2']) ? ' ' . $conf['PS_SHOP_ADDR2'] : '') . ' ' . $conf['PS_SHOP_CODE'] . ' ' . $conf['PS_SHOP_CITY'] . ' ' . $conf['PS_SHOP_COUNTRY'] . ((isset($conf['PS_SHOP_STATE']) and !empty($conf['PS_SHOP_STATE'])) ? ', ' . $conf['PS_SHOP_STATE'] : '') : '', 0, 1, 'C', 1); $pdf->Ln(5); $pdf->SetFont(self::fontname(), '', 9); $pdf->Cell(0, 6, self::l('Upon receiving your package, we will notify you by e-mail. We will then begin processing the reimbursement of your order total.'), 0, 2, 'L'); $pdf->Cell(0, 6, self::l('Let us know if you have any questions.'), 0, 2, 'L'); $pdf->Ln(5); $pdf->SetFont(self::fontname(), 'B', 10); $pdf->Cell(0, 6, self::l('If the conditions of return listed above are not respected,'), 'TRL', 2, 'C'); $pdf->Cell(0, 6, self::l('we reserve the right to refuse your package and/or reimbursement.'), 'BRL', 2, 'C'); return $pdf->Output(sprintf('%06d', self::$order->id) . '.pdf', $mode); }