コード例 #1
0
 function Header()
 {
     global $oID, $order, $address_left, $address_top, $sender, $format_id_text, $have_customers_order_reference;
     global $Y_Fields_Name_position, $Y_Table_Position, $invoice_start_top, $info, $invoice_items_per_page;
     global $print_billing_address, $print_delivery_address, $invoice_items_per_page0, $invoice_items_per_page_next;
     global $use_line_break;
     $this->SetFont($this->font, NORMAL, 8);
     if (!$this->impressum) {
         $this->impressum = array();
         $store = nl2br(STORE_NAME_ADDRESS);
         $store = explode(HTML_BR, $store);
         $lines = sizeof($store) - 1;
         for ($i = 0; $i <= $lines; $i++) {
             $s = trim($store[$i]);
             if ($i == $lines) {
                 $this->impressum[] = EMPTY_STRING;
                 $l_s = strtolower($s);
                 if (strpos($l_s, strtolower(TEXT_FON)) === false) {
                     if (strpos($l_s, 'tel') === false) {
                         $s = TEXT_FON . DOT . COLON_BLANK . $s;
                     }
                 }
             }
             $this->store_impressum_string($s);
         }
         $this->store_impressum_string('eMail' . COLON_BLANK . STORE_OWNER_EMAIL_ADDRESS);
         $s = HTTP_SERVER;
         if (strpos($s, 'localhost') > 0) {
             $store = explode('@', STORE_OWNER_EMAIL_ADDRESS);
             $s = "http://www." . $store[1];
         }
         $this->store_impressum_string('Web' . COLON_BLANK . $s);
         $this->impressum_lines = sizeof($this->impressum);
         $this->impressum_left = ceil($this->w - $this->rMargin - $this->max_impressum_line_length);
     }
     $this->{$page}++;
     $is_firstpage = $this->page == 1;
     $top = $this->lMargin;
     //4
     $left = $this->impressum_left;
     $link = olc_href_link('index.php', $this->language_parameter, NONSSL, false, true, false, true);
     $image = CURRENT_TEMPLATE_IMG . 'invoice_logo.jpg';
     if (file_exists($image)) {
         $top = $this->tMargin;
         $this->Image($image, $this->lMargin, $top, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, $link);
     }
     for ($i = 0; $i < $this->impressum_lines; $i++) {
         $this->Text($left, $top, $this->impressum[$i]);
         $top += $this->lines_height;
     }
     $w = ($this->w - $this->lMargin - $this->lMargin) / 2;
     if ($is_firstpage) {
         //Sender info
         $this->SetFont($this->font, BOLD_UNDERLINE, 6);
         $this->SetY($address_top);
         $this->SetX($address_left);
         $this->Cell($w, 0, $sender, 0, LEFT);
         switch ($this->document) {
             case $this->document_order:
                 //Customer address
                 $address = $order->customer;
                 break;
             case $this->document_invoice:
                 //Delivery address
                 $address = $order->billing;
                 break;
             case $this->document_packingslip:
                 //Delivery address
                 $address = $order->delivery;
                 break;
         }
         $this->SetFont($this->font, NORMAL, 10);
         $this->SetY($address_top + $this->lines_height);
         $this->SetX($address_left);
         $this->MultiCell($w, $this->lines_height, olc_address_format($address[$format_id_text], $address, EMPTY_STRING, EMPTY_STRING, TILDE), 0, LEFT);
     }
     //Draw invoice type text text
     $this->SetFont($this->font, BOLD, 16);
     $this->SetY($invoice_start_top - 3);
     $x = $this->lMargin;
     $this->SetX($x - $this->cMargin);
     $this->MultiCell($w, $this->lines_height, $this->doc_type, 0, LEFT);
     $this->SetFont($this->font, NORMAL, 10);
     //Draw Order Number, Customer Number Date & Payment method
     $top = $invoice_start_top - $this->lines_height * 4;
     $info_items = sizeof($info) - 1;
     if ($have_customers_order_reference) {
         $cori = $info_items;
     } else {
         $cori = -1;
     }
     for ($i = 0; $i <= $info_items; $i++) {
         $set_bold = $i == 0 || $i == $cori;
         if ($set_bold) {
             $this->SetFont($this->font, BOLD, 10);
         }
         $max_info_len = max($max_info_len, $this->GetStringWidth($info[$i]));
         if ($set_bold) {
             $this->SetFont($this->font, NORMAL, 10);
         }
     }
     $top = $invoice_start_top - $this->lines_height * 4;
     $left = $this->w - $this->rMargin - $this->GetStringWidth(DATE);
     $this->Text($left, $top, DATE);
     $left = $this->w - $this->rMargin - $max_info_len;
     $top = $invoice_start_top;
     for ($i = 0; $i <= $info_items; $i++) {
         $set_bold = $i == 0 || $i == $cori;
         if ($set_bold) {
             $this->SetFont($this->font, BOLD, 10);
         }
         $this->Text($left, $top, $info[$i]);
         $top += $this->lines_height;
         if ($set_bold) {
             $this->SetFont($this->font, NORMAL, 10);
         }
     }
     //Invoice fields Name position
     $Y_Fields_Name_position = $top;
     //	+$this->lines_height;	//$invoice_start_top;
     if ($is_firstpage) {
         $standard_address_lines = 7;
         if ($print_billing_address || $print_delivery_address) {
             $print_it = array();
             $print_header = array();
             $print_address = array();
             switch ($this->document) {
                 case $this->document_order:
                     if ($print_billing_address) {
                         $print_it[0] = true;
                         $print_header[0] = PRINT_INVOICE_BILL_TO;
                         $print_address[0] = $order->billing;
                     }
                     if ($print_delivery_address) {
                         $print_it[1] = true;
                         $print_header[1] = PRINT_INVOICE_SHIP_TO;
                         $print_address[1] = $order->delivery;
                     }
                     break;
                 case $this->document_invoice:
                     if ($print_billing_address) {
                         $print_it[0] = true;
                         $print_header[0] = PRINT_INVOICE_SHIP_TO;
                         $print_address[0] = $order->delivery;
                     }
                     if ($print_delivery_address) {
                         $print_it[1] = true;
                         $print_header[1] = PRINT_INVOICE_SOLD_TO;
                         $print_address[1] = $order->customer;
                     }
                     break;
                 case $this->document_packingslip:
                     if ($print_billing_address) {
                         $print_it[0] = true;
                         $print_header[0] = PRINT_INVOICE_BILL_TO;
                         $print_address[0] = $order->billing;
                     }
                     if ($print_delivery_address) {
                         $print_it[1] = true;
                         $print_header[1] = PRINT_INVOICE_SOLD_TO;
                         $print_address[1] = $order->customer;
                     }
                     break;
             }
             $x = $this->lMargin;
             $Y_Fields_Name_position += $this->lines_height;
             for ($i = 0; $i < 2; $i++) {
                 $y = $Y_Fields_Name_position;
                 if ($print_it[$i]) {
                     $address = olc_address_format($print_address[$i][$format_id_text], $print_address[$i], EMPTY_STRING, EMPTY_STRING, TILDE);
                     $current_print_header = $print_header[$i];
                     $address_line = explode(TILDE, $address);
                     $lines = sizeof($address_line) - 1;
                     $max_address_lines = max($max_address_lines, $lines);
                     if ($i) {
                         if ($printed) {
                             if ($right_justify_3rd_address) {
                                 $this->SetFont($this->font, NORMAL, 10);
                                 $address_line = explode(TILDE, $address);
                                 $lines = sizeof($address_line) - 1;
                                 $max_address_lines = max($max_address_lines, $lines);
                                 for ($j = 0; $j <= $lines; $j++) {
                                     $s = $address_line[$j];
                                     $l_w = max($l_w, $this->GetStringWidth($s));
                                 }
                             }
                             $this->SetFont($this->font, BOLD, 10);
                             $l_w = max($l_w, $this->GetStringWidth($current_print_header));
                             $x = $this->w - $this->rMargin - $l_w;
                         }
                         $this->SetY($y);
                         $this->SetX($x);
                         $this->SetFont($this->font, BOLD, 10);
                         $this->Cell($w, 0, $current_print_header);
                         $this->SetFont($this->font, NORMAL, 10);
                         $y += $this->lines_height / 2;
                         $this->SetY($y);
                         $this->SetX($x);
                         $this->MultiCell($w, $this->lines_height, $address, 0, LEFT);
                         $max_y = max($max_y, $this->GetY());
                         $x += $w;
                         $printed = true;
                     }
                 }
             }
             $print_billing_address = false;
             $print_delivery_address = false;
             $Y_Fields_Name_position = $max_y + $this->lines_height * 2;
         } else {
             $max_address_lines = 0;
         }
         $invoice_items_per_page += $standard_address_lines - $max_address_lines;
         //Next page can hold more items, as the delivery/billing/order-addresses will not be repeated!
         $invoice_items_per_page_next = $invoice_items_per_page0 + $standard_address_lines;
         $invoice_items_per_page0 = $invoice_items_per_page;
     } else {
         $Y_Fields_Name_position += $this->lines_height;
     }
     $Y_Table_Position = $Y_Fields_Name_position + $this->lines_height;
     output_invoice_header();
     if ($use_line_break) {
         $Y_Table_Position += $this->lines_height;
     }
     //Table position, under Fields Name
 }
コード例 #2
0
 function Header()
 {
     global $oID, $order, $address_left, $address_top, $sender, $format_id_text, $invoice_start_left;
     global $Y_Fields_Name_position, $Y_Table_Position;
     if (!$this->page) {
         $this->impressum = array();
         //$image_width=$this->info['w']/$this->k;
         //$image_height=$this->info['h']/$this->k;
         $store = nl2br(STORE_NAME_ADDRESS);
         $store = explode(HTML_BR, $store);
         $lines = sizeof($store) - 1;
         for ($i = 0; $i <= $lines; $i++) {
             $s = trim($store[$i]);
             if ($i == $lines) {
                 $this->impressum[] = EMPTY_STRING;
                 $l_s = strtolower($s);
                 if (strpos($l_s, strtolower(TEXT_FON)) === false) {
                     if (strpos($l_s, 'tel') === false) {
                         $s = TEXT_FON . '.: ' . $s;
                     }
                 }
             }
             $this->store_impressum_string($s);
         }
         $this->store_impressum_string('eMail: ' . STORE_OWNER_EMAIL_ADDRESS);
         $s = HTTP_SERVER;
         if (strpos($s, 'localhost') > 0) {
             $store = explode('@', STORE_OWNER_EMAIL_ADDRESS);
             $s = "http://www." . $store[1];
         }
         $this->store_impressum_string('Web: ' . $s);
         $this->impressum_lines = sizeof($this->impressum);
         $this->impressum_left = ceil($this->w - $this->rMargin - $this->max_impressum_line_length);
     }
     $this->{$page}++;
     $this->SetFont($this->font, NO_FORMAT, 8);
     $top = $this->lMargin;
     //4
     $left = $this->wc[0];
     $link = olc_href_link('index.php', $this->language_parameter, NONSSL, false, true, false, true);
     $image = CURRENT_TEMPLATE_IMG . 'invoice_logo.jpg';
     $top = $this->tMargin;
     $this->Image($image, $this->lMargin, $top, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, $link);
     for ($i = 0; $i < $this->impressum_lines; $i++) {
         $this->Text($left, $top, $this->impressum[$i]);
         $top += $this->lines_height;
     }
     if ($this->page == 1) {
         //Sender info
         $this->SetFont($this->font, BOLD_UNDERLINE, 8);
         $this->SetX($address_left);
         $this->SetY($address_top);
         $this->MultiCell(85, $this->lines_height, $sender, 0, LEFT);
         if ($this->print_invoice) {
             //Billing address
             $format_id = $order->billing[$format_id_text];
             $address = $order->billing;
         } else {
             //Billing address
             $format_id = $order->delivery[$format_id_text];
             $address = $order->delivery;
         }
         $this->SetFont($this->font, NO_FORMAT, 10);
         $this->SetX($address_left);
         $this->SetY($address_top);
         $this->MultiCell(85, 45, olc_address_format($format_id, $address, EMPTY_STRING, EMPTY_STRING, NEW_LINE), 0, LEFT);
     }
     //Draw invoice type text text
     $this->SetFont($this->font, BOLD_UNDERLINE, 16);
     $this->SetX($address_left);
     $this->SetY($invoice_start_left);
     $this->MultiCell(85, $this->lines_height, $this->doc_type, 0, LEFT);
     $this->SetFont($this->font, NO_FORMAT, 10);
     if ($this->page > 1) {
         $page_text = str_replace(HASH, $this->PageNo(), PRINT_INVOICE_PAGE);
         $this->Text($left, $address_left, $this->GetY() + $this->lines_height);
     }
     //Draw Order Number, Customer Number Date & Payment method
     $info = array();
     $info[] = PRINT_INVOICE_ORDERNR . olc_db_input($oID);
     $info[] = PRINT_INVOICE_CUSTOMERNR . $order->customers['customers_cid'];
     $info[] = PRINT_INVOICE_DATE . olc_date_short($order->info['date_purchased']);
     $info[] = PRINT_INVOICE_PAYMENT_METHOD . $order->info['payment_method'];
     for ($i = 0; $i < sizeof($info); $i++) {
         $max_info_len = max($max_info_len, $this->GetStringWidth($info[$i]));
     }
     $left = $this->w - $this->lMargin - $max_info_len;
     $top = $invoice_start_top;
     for ($i = 0; $i < sizeof($info); $i++) {
         $this->Text($left, $top, $info[$i]);
         $top += $this->lines_height;
     }
     //Invoice fields Name position
     $Y_Fields_Name_position = $top;
     //Table position, under Fields Name
     $Y_Table_Position = $Y_Fields_Name_position + $this->lines_height;
     output_invoice_header($Y_Fields_Name_position);
 }