staceyd Posted August 3, 2007 Share Posted August 3, 2007 Hi, I've installed the Print Label contrib from here: http://www.oscommerce.com/community/contri...ll/search,label, but can't get it to start in different positions like it's supposed to do. For example, if you want to print a label, but have already used 5 labels on the sheet, then you input in the box (which is there on the admin page) to start printing on position 6. There is a place on this script below that is commented out and is about startpos - does that have something to do with it? Otherwise, it works great. Please help if you can. Thanks!! Stacey <?php require('includes/application_top.php'); if ($HTTP_GET_VARS['mkey']) { $key = $HTTP_GET_VARS['mkey']; $message = $error[$key]; $HTTP_GET_VARS['act'] = 0; } if ($HTTP_GET_VARS['act'] == '') { $HTTP_GET_VARS['act'] = 0; } if (strlen($HTTP_GET_VARS['act']) == 1 && is_numeric($HTTP_GET_VARS['act'])) { switch ($HTTP_GET_VARS['act']) { case 1: require(DIR_WS_CLASSES . 'currencies.php'); require(LABEL_PRINT_INC . 'class.ezpdf.php'); require(DIR_WS_CLASSES . 'order.php'); $pdf = new Cezpdf(array(PAGE_WIDTH, PAGE_HEIGHT)); $currencies = new currencies(); $pdf->selectFont(LABEL_PDF_DIR . 'Helvetica.afm'); $pdf->setFontFamily(LABEL_PDF_DIR . 'Helvetica.afm'); if ($HTTP_POST_VARS['pull_status']){ $pull_w_status = " and o.orders_status = ". $HTTP_POST_VARS['pull_status']; } if ($HTTP_POST_VARS['startpos']){ $startpos = $HTTP_POST_VARS['startpos']; } else { $startpos = 0; } if ($HTTP_POST_VARS['address']){ if ($HTTP_POST_VARS['address'] == "billing") $billing = true; else $billing = false; } else { $billing = false; } $orders_query = tep_db_query("select o.orders_id from " . TABLE_ORDERS . " o where o.orders_id >= '" . tep_db_input($startid) . "'" . $pull_w_status . " ORDER BY o.orders_id ASC"); $number_of_orders = tep_db_num_rows($orders_query); if ($HTTP_POST_VARS['endpos']){ $endpos = $HTTP_POST_VARS['endpos']; } else { $endpos = $number_of_orders; } //$orders_query = tep_db_query("select o.orders_id,h.comments,MIN(h.date_added) from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS_HISTORY . " h where o.date_purchased between '" . tep_db_input($startdate) . "' and '" . tep_db_input($enddate) . "23:59:59' and h.orders_id = o.orders_id" . $pull_w_status . $get_customer_comments . ' group by o.orders_id'); if ($number_of_orders <= 0) { message_handler('NO_ORDERS'); } $number_of_pages = ceil( $number_of_orders / NUM_LABELS_PER_PAGE ); change_color(GENERAL_FONT_COLOR); $start = ( $pdf->ez['pageHeight'] - STARTY ) * $number_of_pages;; $end = LABEL_HEIGHT - STARTY; /** * Code added to print on multiple pages * Removed LIMIT clause from SQL statement * Wrote new loop to print labels * @author Paul Harman */ // Check if a different start column has been requested if($startpos != 0) { $columns = $startpos; } // Iterate over the order count and find label positions for( $a = 0; $a < $number_of_orders; $a++ ) { // Set Y position for this label $label_y = LABEL_HEIGHT * $rows; if( $num == 0 ) { $label_y += STARTY; } // Iterate over the number of columns for( $b = 0; $b < NUM_COLUMNS; $b++ ) { // Set X position for this label $label_x = STARTX + LABEL_WIDTH * $columns; ++$columns; // Decide whether to start a new PDF page if( $label_y + LABEL_HEIGHT > $pdf->ez['pageHeight'] ) { // echo $label_y . " " . LABEL_HEIGHT . " " . $pdf->ez['pageHeight'] . "<br>"; $pdf->ezNewPage(); // We need to reset the Y coordinate for the new page $label_y = STARTY; // And reset the row counter; $rows = 0; } // Check if we have reached the limit of labels if($num >= $endpos) { break(2); } ++$num; // Send coordinates to label printing function print_address($label_x, $pdf->ez['pageHeight'] - $label_y); } // Send fake header to avoid timeout, got this trick from phpMyAdmin $time1 = time(); if ($time1 >= $time0 + 30) { $time0 = $time1; header('X-bpPing: Pong'); } // Reset the column counter $columns = 0; // Increment the rows counter ++$rows; } /*for($y = $start; $y > $end; $y -= LABEL_HEIGHT) { //if ($num != 0) { $pdf->EzNewPage(); } //$y = $pdf->ezText(STORE_NAME_ADDRESS,COMPANY_HEADER_FONT_SIZE); //$y -= 10; for ($x = STARTX; $x < STARTX + NUM_COLUMNS * LABEL_WIDTH; $x += LABEL_WIDTH) { if ($startpos <= $pos && $num < $endpos) { if (print_address($x, $y)) { $num++; } } $pos++; } //$y = $pdf->ezText(next_address(),GENERAL_FONT_SIZE); }// EOWHILE */ //$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,"HELLO"); $pdf_code = $pdf->output(); $fname = LABEL_PDF_DIR . LABEL_PDF_FILE; if ($fp = fopen($fname,'w')) { fwrite($fp,$pdf_code); fclose($fp); } else { message_handler('FAILED_TO_OPEN'); } $message = 'A PDF of ' . $num . ' order(s) was successful! <a href="'.$fname.'"><b>Click here</b></a> to download the order file.'; case 0: require(LABEL_PRINT_INC . 'label_print_header.php'); require(LABEL_PRINT_INC . 'label_print_body.php'); require(LABEL_PRINT_INC . 'label_print_footer.php'); break; default: message_handler(); }//EOSWITCH } else { message_handler('ERROR_INVALID_INPUT'); } // FUNCTION AREA function message_handler($message=''){ if ($message) { header("Location: " . tep_href_link(LABEL_PRINT_FILE, 'mkey=' . $message)); } else { header("Location: " . tep_href_link(LABEL_PRINT_FILE)); } exit(0); } function change_color($color) { global $pdf; list($r,$g,$b) = explode(',', $color); $pdf->setColor($r,$g,$b); } function print_address($x, $y) { global $pdf, $num, $billing, $orders_query; $pos = $y - CUST_ADD_OFFSET; if ($orders = tep_db_fetch_array($orders_query)) { $order = new order($orders['orders_id']); if ($billing == true) { $addressparts = explode("\n", strtoupper(tep_address_format($order->billing['format_id'], $order->billing, 1, '', " \n"))); } else { $addressparts = explode("\n", strtoupper(tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', " \n"))); } foreach($addressparts as $addresspart) { $fontsize = GENERAL_FONT_SIZE; while ($pdf->getTextWidth($fontsize, $addresspart) > LABEL_WIDTH - COLUMN_GAP) { $fontsize--; } //$addresspart = preg_replace("%,[[:space:]]*$%", "", $addresspart); $pdf->addText($x,$pos -=GENERAL_LINE_SPACING,$fontsize,$addresspart); } $store1 = STORE1; $store2 = STORE2; $store3 = STORE3; $store4 = STORE4; $pdf->addText($x,$y - STOREOFFSET1,"8","$store1"); $pdf->addText($x,$y - STOREOFFSET2,"8","$store2"); $pdf->addText($x,$y - STOREOFFSET3,"8","$store3"); $pdf->addText($x,$y - STOREOFFSET4,"8","$store4"); $pdf->addText($x + LABEL_WIDTH - ORDERIDXOFFSET,$y + ORDERIDYOFFSET,ORDERIDFONTSIZE,$orders['orders_id']); } else { return false; } return true; } function verify_date($enddate) { $error = 0; list($year,$month,$day) = explode('-', $enddate); if ((strlen($year) != 4) || !is_numeric($year)) { $error++; } if ((strlen($month) != 2) || !is_numeric($month)) { $error++; } if ((strlen($day) != 2) || !is_numeric($day)) { $error++; } return $error; } ?> Quote Link to comment Share on other sites More sharing options...
From Fan 2 Fans Posted August 22, 2007 Share Posted August 22, 2007 Hi, I've just installed the contribution and I don't have this problem... You should maybe try to reinstall it. Quote Link to comment Share on other sites More sharing options...
staceyd Posted August 22, 2007 Author Share Posted August 22, 2007 Thanks for your reply. I just wonder if it's bumping up against one or more of the other contributions I installed... Thanks again! Stacey Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.