Пример #1
0
 /**
  * 获取唯一实例
  *
  * @param string $sheetTitle        表格名称
  * @return excel
  */
 public static function getInstance($sheetTitle = null)
 {
     if (self::$_instance !== null) {
         return self::$_instance;
     }
     self::$_instance = new self($sheetTitle);
     return self::$_instance;
 }
Пример #2
0
         }
     } else {
         $messageStack->add('header', strip_tags(ENTRY_REQUEST_FORM_AUTHORIZATION_NEEDED));
     }
     break;
 case 'corporate_order':
     if (tep_session_is_registered('customer_id')) {
         $cells = array();
         $file_cells = array();
         $error = false;
         if (is_uploaded_file($_FILES['corporate_file']['tmp_name'])) {
             $ext = strtolower(substr($_FILES['corporate_file']['name'], strrpos($_FILES['corporate_file']['name'], '.') + 1));
             if ($_FILES['corporate_file']['type'] == 'text/plain' && ($ext == 'csv' || $ext == 'txt') || $_FILES['corporate_file']['type'] == 'application/vnd.ms-excel' && ($ext == 'csv' || $ext == 'xls')) {
                 if ($_FILES['corporate_file']['type'] == 'application/vnd.ms-excel' && $ext == 'xls') {
                     require DIR_WS_CLASSES . 'excel.php';
                     $data = new excel();
                     $data->setOutputEncoding('cp1251');
                     $data->read($corporate_file);
                     $cells = $data->sheets[0]['cells'];
                 } else {
                     $file_contents_array = file($_FILES['corporate_file']['tmp_name']);
                     $some_string = $file_contents_array[0];
                     if (strpos($some_string, "\t") !== false) {
                         $delimiter = "\t";
                     } else {
                         $delimiter = ";";
                     }
                     $cells = array();
                     $fp = fopen($_FILES['corporate_file']['tmp_name'], 'r');
                     while (($cell = fgetcsv($fp, 10000, $delimiter)) !== FALSE) {
                         $cells[] = array_merge(array(''), $cell);
Пример #3
0
 public function excel_update()
 {
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         $this->errorOutput('只有管理员可以操作');
     }
     require_once CUR_CONF_PATH . 'lib/excel.class.php';
     $excel = new excel();
     //获取文件扩展名
     $extend = pathinfo($_FILES["excel"]["name"]);
     $extend = strtolower($extend["extension"]);
     //获取文件扩展名结束
     $time = date("Y-m-d-H-i-s");
     //取当前上传的时间
     $name = $time . '.' . $extend;
     //重新组装上传后的文件名
     $uploadfile = CACHE_DIR . $name;
     //上传后的文件名地址
     if ($extend == "xls" && $_FILES["file"]["size"] < 2000000) {
         $tmp_name = $_FILES["excel"]["tmp_name"];
         if ($_FILES["excel"]["error"] > 0) {
             $this->errorOutput("Return Code: " . $_FILES["excel"]["error"] . "<br />");
         } else {
             $excel_info = $excel->show($uploadfile, $tmp_name, $this->user);
             if ($excel_info && is_array($excel_info)) {
                 //取影院信息
                 $sql = "SELECT id,title FROM " . DB_PREFIX . "cinema";
                 $query = $this->db->query($sql);
                 while ($row = $this->db->fetch_array($query)) {
                     $cinema_info[$row['title']] = $row['id'];
                 }
                 //取影片信息
                 $sql = "SELECT id,title FROM " . DB_PREFIX . "movie";
                 $query = $this->db->query($sql);
                 while ($row = $this->db->fetch_array($query)) {
                     $movie_info[$row['title']] = $row['id'];
                 }
                 //处理excel信息
                 foreach ($excel_info as $key => $val) {
                     if ($cinema_info[$key]) {
                         $this->input['cinema_id'] = $cinema_info[$key];
                     } else {
                         $cinema_data = array('title' => trim($key), 'create_time' => TIMENOW, 'org_id' => $this->user['org_id'], 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'ip' => hg_getip());
                         $insert_id = $this->db->insert_data($cinema_data, 'cinema');
                         $this->input['cinema_id'] = $insert_id;
                         $this->db->query("UPDATE " . DB_PREFIX . "cinema SET order_id = {$insert_id}  WHERE id = {$insert_id}");
                     }
                     foreach ((array) $val as $ke => $va) {
                         if ($movie_info[$ke]) {
                             $this->input['movie_id'] = $movie_info[$ke];
                         } else {
                             $movie_data = array('title' => trim($ke), 'status' => 1, 'create_time' => TIMENOW, 'org_id' => $this->user['org_id'], 'user_id' => $this->user['user_id'], 'user_name' => $this->user['user_name'], 'ip' => hg_getip());
                             $insert_id = $this->db->insert_data($movie_data, 'movie');
                             $this->input['movie_id'] = $insert_id;
                             $this->db->query("UPDATE " . DB_PREFIX . "movie SET order_id = {$insert_id}  WHERE id = {$insert_id}");
                         }
                         $this->input['movie_name'] = trim($ke);
                         foreach ((array) $va as $k => $v) {
                             $this->input['dates'] = trim($k);
                             $this->input['data'] = array();
                             foreach ((array) $v as $kk => $vv) {
                                 $tmp = array();
                                 $tmp = explode('|', $vv);
                                 $this->input['data'][] = array('project_time' => trim($tmp[0]), 'hall' => trim($tmp[4]), 'ticket_price' => trim($tmp[3]), 'language' => trim($tmp[1]), 'dimension' => trim($tmp[2]), 'id' => '0');
                             }
                             if ($this->input['data']) {
                                 $this->input['data'] = htmlentities(json_encode($this->input['data']));
                             }
                             $this->input['is_excel'] = 1;
                             $this->create();
                         }
                     }
                 }
                 $this->addItem('success');
                 $this->output();
             } else {
                 $this->errorOutput('导入失败');
             }
         }
     } else {
         $this->errorOutput('文件错误,仅支持xls,文件不能大于2M');
     }
 }
Пример #4
0
 public function export_data($data = array())
 {
     if (!empty($data)) {
         $phpExcel = new excel();
         $prestasi = $phpExcel->setActiveSheetIndex(0);
         //merger
         $phpExcel->getActiveSheet()->mergeCells('A1:L1');
         //manage row hight
         $phpExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
         //style alignment
         $styleArray = array('alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER));
         $phpExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
         $phpExcel->getActiveSheet()->getStyle('A1:L1')->applyFromArray($styleArray);
         //border
         $styleArray1 = array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN)));
         //background
         $styleArray12 = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array('rgb' => 'FFEC8B')));
         //freeepane
         $phpExcel->getActiveSheet()->freezePane('A3');
         //coloum width
         $phpExcel->getActiveSheet()->getColumnDimension('A')->setWidth(4.1);
         $phpExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
         $phpExcel->getActiveSheet()->getColumnDimension('C')->setWidth(15);
         $phpExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
         $phpExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
         $phpExcel->getActiveSheet()->getColumnDimension('F')->setWidth(10);
         $phpExcel->getActiveSheet()->getColumnDimension('G')->setWidth(40);
         $phpExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
         $phpExcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
         $phpExcel->getActiveSheet()->getColumnDimension('J')->setWidth(25);
         $phpExcel->getActiveSheet()->getColumnDimension('K')->setWidth(25);
         $phpExcel->getActiveSheet()->getColumnDimension('L')->setWidth(25);
         $prestasi->setCellValue('A1', 'รายงาน รายชื่อนักเรียน');
         $phpExcel->getActiveSheet()->getStyle('A2:L2')->applyFromArray($styleArray);
         $phpExcel->getActiveSheet()->getStyle('A2:L2')->applyFromArray($styleArray1);
         $phpExcel->getActiveSheet()->getStyle('A2:L2')->applyFromArray($styleArray12);
         $prestasi->setCellValue('A2', 'No');
         $prestasi->setCellValue('B2', 'รหัส');
         $prestasi->setCellValue('C2', 'คํานําหน้าชื่อ');
         $prestasi->setCellValue('D2', 'ชื่อ-นามสกุล');
         $prestasi->setCellValue('E2', 'รหัสบัตรประชาชน');
         $prestasi->setCellValue('F2', 'วันเกิด');
         $prestasi->setCellValue('G2', 'ปีการศึกษา');
         $prestasi->setCellValue('H2', 'ห้องเรียน');
         $prestasi->setCellValue('I2', 'ที่อยู่');
         $prestasi->setCellValue('J2', 'เบอร์โทรนักเรียน');
         $prestasi->setCellValue('K2', 'เบอร์โทรผู้ปกครอง');
         $prestasi->setCellValue('L2', 'วันที่เข้าเรียน');
         $no = 0;
         $rowexcel = 2;
         foreach ($data as $row) {
             $no++;
             $rowexcel++;
             $phpExcel->getActiveSheet()->getStyle('A' . $rowexcel . ':L' . $rowexcel)->applyFromArray($styleArray);
             $phpExcel->getActiveSheet()->getStyle('A' . $rowexcel . ':L' . $rowexcel)->applyFromArray($styleArray1);
             $prestasi->setCellValue('A' . $rowexcel, $no);
             $prestasi->setCellValue('B' . $rowexcel, $row['STU_CODE']);
             $prestasi->setCellValue('C' . $rowexcel, $row['STU_TITLE']);
             $prestasi->setCellValue('D' . $rowexcel, $row['STU_FNAME'] . ' ' . $row['STU_LNAME']);
             $prestasi->setCellValue('E' . $rowexcel, $row['ID_CARD']);
             $prestasi->setCellValue('F' . $rowexcel, $row['BIRTH_DATE']);
             $prestasi->setCellValue('G' . $rowexcel, $row['GRADE_NAME']);
             $prestasi->setCellValue('H' . $rowexcel, $row['CLASS_NUM']);
             $prestasi->setCellValue('I' . $rowexcel, $row['STU_ADD']);
             $prestasi->setCellValue('J' . $rowexcel, $row['STU_TEL']);
             $prestasi->setCellValue('K' . $rowexcel, $row['STU_PTEL']);
             $prestasi->setCellValue('L' . $rowexcel, $row['STU_INDATE']);
         }
         $prestasi->setTitle('รายงาน รายชื่อนักเรียน');
         header("Content-Type: application/vnd.ms-excel");
         header("Content-Disposition: attachment; filename=\"Students Report.xls\"");
         header("Cache-Control: max-age=0");
         $objWriter = PHPExcel_IOFactory::createWriter($phpExcel, "Excel5");
         $objWriter->save("php://output");
     }
 }
Пример #5
0
 public function excel_update()
 {
     $data_prms['_action'] = 'create';
     $this->verify_content_prms($data_prms);
     if ($this->user['group_type'] > MAX_ADMIN_TYPE) {
         //$this->errorOutput('只有管理员可以操作');
     }
     include CUR_CONF_PATH . 'lib/excel.class.php';
     $excel = new excel();
     //获取文件扩展名
     $extend = pathinfo($_FILES["excel"]["name"]);
     $extend = strtolower($extend["extension"]);
     //获取文件扩展名结束
     $time = date("Y-m-d-H-i-s");
     //取当前上传的时间
     $name = $time . '.' . $extend;
     //重新组装上传后的文件名
     $uploadfile = CACHE_DIR . $name;
     //上传后的文件名地址
     if ($extend == "xls" && $_FILES["file"]["size"] < 2000000) {
         $tmp_name = $_FILES["excel"]["tmp_name"];
         $strtotimes = strtotime(date('Ymd'));
         $key = md5_file($tmp_name);
         $sql = " SELECT filekey FROM " . DB_PREFIX . "con_fileinfo WHERE filekey = '" . $key . "' AND create_time =" . $strtotimes;
         $re = $this->db->query_first($sql);
         if ($_FILES["excel"]["error"] > 0) {
             $this->errorOutput("Return Code: " . $_FILES["excel"]["error"] . "<br />");
         } elseif ($re['filekey'] == $key) {
             $this->errorOutput('已经导入成功,无需重复导入');
         } else {
             $sort_id = intval($this->input['sort_id']);
             $isupload = $excel->show($uploadfile, $tmp_name, $this->user, $sort_id);
             if ($isupload) {
                 $sql = 'INSERT INTO ' . DB_PREFIX . 'con_fileinfo SET filekey = \'' . $key . '\',create_time =' . $strtotimes;
                 $this->db->query($sql);
                 // 删除除今天以外的文件MD5值.
                 $sql = " DELETE FROM " . DB_PREFIX . "con_fileinfo WHERE 1 AND create_time NOT IN (" . $strtotimes . ")";
                 $this->db->query($sql);
                 $this->addItem($isupload);
                 $this->output();
             } else {
                 $this->errorOutput('导入失败');
             }
         }
     } else {
         $this->errorOutput('文件错误,仅支持xls,文件不能大于2M');
     }
 }
Пример #6
0
require_once 'connect.php';
$id_get = $_POST['id_get'];
$semester = $_POST['semester'];
$sy = $_POST['sy'];
function HeaderingExcel($filename)
{
    header("Content-type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename={$filename}");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
    header("Pragma: public");
}
// HTTP headers
HeaderingExcel('teacher.xls');
// Creating a workbook
$workbook = new excel("-");
// Creating the first worksheet
$worksheet1 =& $workbook->add_worksheet('teacher');
$worksheet1->freeze_panes(1, 0);
$worksheet1->set_column(0, 0, 25);
$worksheet1->set_column(1, 1, 20);
$worksheet1->set_column(1, 2, 20);
$worksheet1->set_column(1, 3, 20);
$worksheet1->set_column(1, 4, 20);
$worksheet1->set_column(1, 5, 20);
$worksheet1->set_column(1, 6, 20);
//row
$worksheet1->set_row(8, 50);
$query = mysql_query("select * from schedule where  teacher='{$id_get}' and semester='{$semester}' and sy='{$sy}'") or die(mysql_error());
$row = mysql_fetch_array($query);
$name = $row['teacher'];
Пример #7
0
 function quote($method = '')
 {
     global $order, $cart, $currencies, $shipping_weight, $customer_type, $customer_id;
     $currency_value = $currencies->currencies[MODULE_SHIPPING_FOREIGN_CURRENCY]['value'];
     $calculate_by_weight = false;
     $calculate_by_qty = false;
     if (tep_not_null(MODULE_SHIPPING_FOREIGN_HANDLING_WEIGHT)) {
         $calculate_by_weight = true;
         $base_shipping = str_replace(',', '.', MODULE_SHIPPING_FOREIGN_HANDLING_WEIGHT);
     } else {
         $calculate_by_qty = true;
         $base_shipping = str_replace(',', '.', MODULE_SHIPPING_FOREIGN_HANDLING);
     }
     $countries_cost = array_map('trim', explode(',', MODULE_SHIPPING_FOREIGN_COEFFICIENTS));
     $size = sizeof($countries_cost);
     for ($i = 0, $n = $size; $i < $n; $i++) {
         list($countries_iso_code_2, $countries_additional_shipping_cost) = explode(':', $countries_cost[$i]);
         if ($order->delivery['country']['iso_code_2'] == $countries_iso_code_2) {
             $base_shipping += $countries_additional_shipping_cost;
             break;
         }
     }
     $shipping_1 = 0;
     $shipping_2 = 0;
     $sum_1 = 0;
     $sum_2 = 0;
     $total_qty = 0;
     $total_weight = 0;
     $periodicals_weights = array();
     $periodicals_qtys = array();
     if (is_object($cart)) {
         $products_in_cart = $cart->get_products();
         reset($products_in_cart);
         while (list($i, $product_in_cart) = each($products_in_cart)) {
             if ($product_in_cart['periodicity'] > 0) {
                 if ($calculate_by_weight) {
                     $shipping_2 += ($base_shipping + (ceil($product_in_cart['weight']) - 1) * str_replace(',', '.', MODULE_SHIPPING_FOREIGN_COST_WEIGHT)) * $product_in_cart['quantity'];
                 } elseif ($product_in_cart['weight'] > 0) {
                     $shipping_2 += $base_shipping * $product_in_cart['quantity'];
                 }
                 $sum_2 += $product_in_cart['final_price'] * $product_in_cart['quantity'];
                 $periodicals_weights[] = $product_in_cart['weight'];
                 $periodicals_qtys[] = $product_in_cart['quantity'];
             } else {
                 $total_qty += $product_in_cart['quantity'];
                 $total_weight += $product_in_cart['weight'] * $product_in_cart['quantity'];
                 $sum_1 += $product_in_cart['final_price'] * $product_in_cart['quantity'];
             }
         }
     }
     $shipping_2 = 0;
     if ($total_qty > 0) {
         if ($calculate_by_weight) {
             $shipping_1 = $base_shipping + (ceil($total_weight) - 1) * str_replace(',', '.', MODULE_SHIPPING_FOREIGN_COST_WEIGHT);
         } else {
             $shipping_1 = $base_shipping + ($total_qty - 1) * str_replace(',', '.', MODULE_SHIPPING_FOREIGN_COST);
         }
     }
     $free_shipping = str_replace(',', '.', MODULE_SHIPPING_FOREIGN_FREE);
     if (MODULE_SHIPPING_FOREIGN_FREE_SPECIFY == 'False' && $customer_type == 'corporate') {
         $free_shipping = 0;
     }
     if ($free_shipping > 0 && defined('MODULE_SHIPPING_FOREIGN_FREE_ONLY')) {
         if (tep_not_null(MODULE_SHIPPING_FOREIGN_FREE_ONLY)) {
             $only_countries = array_map('trim', explode(',', MODULE_SHIPPING_FOREIGN_FREE_ONLY));
             if (!in_array($order->delivery['country']['iso_code_2'], $only_countries)) {
                 $free_shipping = 0;
             }
         }
     }
     if ($free_shipping > 0 && defined('MODULE_SHIPPING_FOREIGN_FREE_NOT_ONLY')) {
         if (tep_not_null(MODULE_SHIPPING_FOREIGN_FREE_NOT_ONLY)) {
             $only_countries = array_map('trim', explode(',', MODULE_SHIPPING_FOREIGN_FREE_NOT_ONLY));
             if (in_array($order->delivery['country']['iso_code_2'], $only_countries)) {
                 $free_shipping = 0;
             }
         }
     }
     if ($free_shipping > 0) {
         if ($sum_1 * $currency_value >= $free_shipping) {
             $shipping_1 = 0;
         }
         if ($shipping_1 == 0 && $total_qty > 0) {
             $this->icon = ' (<span class="errorText">' . sprintf(MODULE_SHIPPING_FOREIGN_TEXT_FREE_SHIPPING, $currencies->format($free_shipping, false, MODULE_SHIPPING_FOREIGN_CURRENCY)) . '</span>)';
         }
     }
     if ($currency_value > 0) {
         $shipping_cost = str_replace(',', '.', ($shipping_1 + $shipping_2) / $currency_value);
     }
     $shipping_cost = tep_round($shipping_cost, $currencies->get_decimal_places(MODULE_SHIPPING_FOREIGN_CURRENCY));
     $methods = array();
     if (($customer_id == 2 || $customer_id == 37056) && (SHOP_ID == 14 || SHOP_ID == 16)) {
         include DIR_WS_CLASSES . 'excel.php';
         $data = new excel();
         $data->setOutputEncoding('cp1251');
         $data->read(DIR_WS_MODULES . 'shipping/foreign.xls');
         $cells = $data->sheets[0]['cells'];
         $cells_1 = $data->sheets[1]['cells'];
         //		echo '<pre>' . print_r($cells_1, true) . '</pre>'; die();
         $country_found = false;
         $fc_zone = 0;
         $pr_zone = 0;
         $eu_zone = 0;
         $is_us = false;
         $is_eu = false;
         $fc_shipping_cost = 0;
         $pr_shipping_cost = 0;
         $eu_shipping_cost = 0;
         $us_shipping_cost = 0;
         reset($cells);
         while (list(, $cell) = each($cells)) {
             if ($cell[1] == $order->delivery['country']['iso_code_2']) {
                 $fc_zone = (int) $cell[2];
                 $pr_zone = (int) $cell[3];
                 if ($fc_zone == '0') {
                     $eu_zone = 0;
                     $fc_zone = 0;
                     $pr_zone = 0;
                     $is_us = true;
                 }
                 if ($cell[4] > 0) {
                     $eu_zone = (int) $cell[4];
                     $fc_zone = 0;
                     $pr_zone = 0;
                     $is_eu = true;
                 }
                 $country_found = true;
                 break;
             }
         }
         if ($country_found) {
             $fc_shipping_title = $cells_1[1][1];
             $pr_shipping_title = $cells_1[1][6];
             $us_shipping_title = $cells_1[1][11];
             $eu_shipping_title = $cells_1[1][16];
             if ($is_us) {
                 $pounds_total_weight = ceil($total_weight / 0.4536) * 0.4536;
                 $us_shipping_cost = ($pounds_total_weight * $cells_1[2][13] + $cells_1[2][14]) / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                 if ($free_shipping > 0 && $sum_1 * $currency_value >= $free_shipping) {
                     $us_shipping_cost = 0;
                     $this->icon = ' (<span class="errorText">' . sprintf(MODULE_SHIPPING_FOREIGN_TEXT_FREE_SHIPPING, $currencies->format($free_shipping, false, MODULE_SHIPPING_FOREIGN_CURRENCY)) . '</span>)';
                 }
                 reset($periodicals_weights);
                 while (list($i, $periodicals_weight) = each($periodicals_weights)) {
                     $pounds_periodicals_weight = ceil($periodicals_weight / 0.4536) * 0.4536;
                     $us_shipping_cost += ($pounds_periodicals_weight * $cells_1[2][13] + $cells_1[2][14]) * $periodicals_qtys[$i] / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                 }
                 $methods[] = array('id' => $this->code . '_media', 'title' => $us_shipping_title, 'cost' => $us_shipping_cost);
             } elseif ($is_eu) {
                 reset($cells_1);
                 while (list(, $cell) = each($cells_1)) {
                     if ($cell[1] == $eu_zone) {
                         $cell_18 = $cell[18];
                         $cell_19 = $cell[19];
                         if (MODULE_SHIPPING_FOREIGN_CURRENCY != 'EUR') {
                             $cell_18 *= $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY) / $currencies->get_value('EUR');
                             $cell_19 *= $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY) / $currencies->get_value('EUR');
                         }
                         $pounds_total_weight = ceil($total_weight / 2) * 2;
                         $eu_shipping_cost = ($total_weight * $cell_18 + $cell_19) / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                         if ($free_shipping > 0 && $sum_1 * $currency_value >= $free_shipping) {
                             $eu_shipping_cost = 0;
                             $this->icon = ' (<span class="errorText">' . sprintf(MODULE_SHIPPING_FOREIGN_TEXT_FREE_SHIPPING, $currencies->format($free_shipping, false, MODULE_SHIPPING_FOREIGN_CURRENCY)) . '</span>)';
                         }
                         reset($periodicals_weights);
                         while (list($i, $periodicals_weight) = each($periodicals_weights)) {
                             $pounds_periodicals_weight = ceil($periodicals_weight / 2) * 2;
                             $eu_shipping_cost += ($pounds_periodicals_weight * $cell_18 + $cell_19) * $periodicals_qtys[$i] / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                         }
                         $methods[] = array('id' => $this->code . '_dpd', 'title' => $eu_shipping_title, 'cost' => $eu_shipping_cost);
                     }
                 }
             } else {
                 while (list(, $cell) = each($cells_1)) {
                     if ($cell[1] == $fc_zone) {
                         $use_this_method = true;
                         if ($cell[2] > 0) {
                             if ($total_weight > $cell[2]) {
                                 $use_this_method = false;
                             } else {
                                 reset($periodicals_weights);
                                 while (list(, $periodicals_weight) = each($periodicals_weights)) {
                                     if ($periodicals_weight > $cell[2]) {
                                         $use_this_method = false;
                                     }
                                 }
                             }
                         }
                         if ($use_this_method) {
                             $pounds_total_weight = ceil($total_weight * 4 / 0.4536) * 0.4536 / 4;
                             $fc_shipping_cost = ($pounds_total_weight * $cell[3] + $cell[4]) / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                             if ($free_shipping > 0 && $sum_1 * $currency_value >= $free_shipping) {
                                 $fc_shipping_cost = 0;
                                 $this->icon = ' (<span class="errorText">' . sprintf(MODULE_SHIPPING_FOREIGN_TEXT_FREE_SHIPPING, $currencies->format($free_shipping, false, MODULE_SHIPPING_FOREIGN_CURRENCY)) . '</span>)';
                             }
                             reset($periodicals_weights);
                             while (list($i, $periodicals_weight) = each($periodicals_weights)) {
                                 $pounds_periodicals_weight = ceil($periodicals_weight * 4 / 0.4536) * 0.4536 / 4;
                                 $fc_shipping_cost += ($pounds_periodicals_weight * $cell[3] + $cell[4]) * $periodicals_qtys[$i] / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                             }
                             $methods[] = array('id' => $this->code . '_firstclass', 'title' => $fc_shipping_title, 'cost' => $fc_shipping_cost);
                         }
                     }
                     if ($cell[6] == $pr_zone) {
                         $use_this_method = true;
                         if ($cell[7] > 0) {
                             if ($total_weight > $cell[7]) {
                                 $use_this_method = false;
                             } else {
                                 reset($periodicals_weights);
                                 while (list(, $periodicals_weight) = each($periodicals_weights)) {
                                     if ($periodicals_weight > $cell[7]) {
                                         $use_this_method = false;
                                     }
                                 }
                             }
                         }
                         if ($use_this_method) {
                             $pounds_total_weight = ceil($total_weight / 0.4536) * 0.4536;
                             $pr_shipping_cost = ($pounds_total_weight * $cell[8] + $cell[9]) / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                             if ($free_shipping > 0 && $sum_1 * $currency_value >= $free_shipping) {
                                 $pr_shipping_cost = 0;
                                 $this->icon = ' (<span class="errorText">' . sprintf(MODULE_SHIPPING_FOREIGN_TEXT_FREE_SHIPPING, $currencies->format($free_shipping, false, MODULE_SHIPPING_FOREIGN_CURRENCY)) . '</span>)';
                             }
                             if ($free_shipping > 0 && $sum_1 * $currency_value >= $free_shipping) {
                                 $pr_shipping_cost = 0;
                             }
                             reset($periodicals_weights);
                             while (list($i, $periodicals_weight) = each($periodicals_weights)) {
                                 $pounds_periodicals_weight = ceil($periodicals_weight / 0.4536) * 0.4536;
                                 $pr_shipping_cost += ($pounds_periodicals_weight * $cell[3] + $cell[4]) * $periodicals_qtys[$i] / $currencies->get_value(MODULE_SHIPPING_FOREIGN_CURRENCY);
                             }
                             $methods[] = array('id' => $this->code . '_priority', 'title' => $pr_shipping_title, 'cost' => $pr_shipping_cost);
                         }
                     }
                 }
             }
         }
     }
     if (sizeof($methods) == 0) {
         $methods = array(array('id' => $this->code, 'title' => MODULE_SHIPPING_FOREIGN_WAY, 'cost' => $shipping_cost));
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_FOREIGN_TITLE, 'methods' => $methods);
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
     }
     if (tep_not_null($this->icon)) {
         $this->quotes['icon'] = $this->icon;
     }
     return $this->quotes;
 }
Пример #8
0
//require_once('OLEwriter.php');
//require_once('BIFFwriter.php');
require_once 'Worksheet.php';
require_once 'Workbook.php';
function HeaderingExcel($filename)
{
    header("Content-type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename={$filename}");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
    header("Pragma: public");
}
// HTTP headers
HeaderingExcel('test.xls');
// Creating a workbook
$workbook = new excel("-");
// Creating the first worksheet
$worksheet1 =& $workbook->add_worksheet('First One');
$worksheet1->set_column(1, 1, 40);
$worksheet1->set_row(1, 20);
$worksheet1->write_string(1, 1, "This worksheet's name is " . $worksheet1->get_name());
$worksheet1->write(2, 1, "http://www.phpclasses.org/browse.html/package/767.html");
$worksheet1->write_number(3, 0, 11);
$worksheet1->write_number(3, 1, 1);
$worksheet1->write_string(3, 2, "by four is");
$worksheet1->write_formula(3, 3, "=A4 * (2 + 2)");
//$worksheet1->write_formula(3, 3, "= SUM(A4:B4)");
$worksheet1->write(5, 4, "= POWER(2,3)");
$worksheet1->write(4, 4, "= SUM(5, 5, 5)");
//$worksheet1->write_formula(4, 4, "= LN(2.71428)");
//$worksheet1->write_formula(5, 4, "= SIN(PI()/2)");