if ($p == '') {
        $messagebox->add('Please enter a Product ID / Code / EAN');
    } elseif (strlen($p) == 13 && is_numeric($p)) {
        $pinfo = $class_ean->getProductArticle($p);
        $pid = $pinfo['products_id'];
        $aid = $pinfo['products_articles_id'];
        $ps = $class_pm->stockRetrieveDetail($fg_whid, $pid, $aid);
        openStockDetail($ps['products_stock_id']);
    } else {
        if (substr($p, 0, 1) == '0') {
            $products = $class_pm->retrieveList("products_model='{$p}'");
            if (count($products) > 0) {
                $p = $products[0]['products_id'];
            }
        }
        $articles = $class_pa->retrieveList($p);
        if (count($articles) == 0) {
            $ps = $class_pm->stockRetrieveDetail($fg_whid, $p, '0');
            if (!is_null($ps)) {
                openStockDetail($ps['products_stock_id']);
            }
        } else {
            $content .= drawProductInfo($p, $articles);
            $content .= '<h3 style="clear:both;padding-top:30px;">or open another product below</h3>';
        }
    }
} elseif (isset($_GET['binid'])) {
    $bin_id = tep_db_prepare_input($_GET['binid']);
    $bin = $class_bin->retrieveBinDetail($bin_id);
    if (!is_null($bin['products_stock_id'])) {
        openStockDetail($bin['products_stock_id']);
예제 #2
0
 function isReadyForGraphics()
 {
     use_class('products_articles');
     $class_pa = new products_articles();
     use_class('products_minierp');
     $class_pm = new products_minierp();
     $drafts = $this->retrieveDrafts("approve_status!='R'");
     if (count($drafts) > 0) {
         $products = $this->retrieveProducts();
         $drafts_products = array();
         foreach ($products as $p) {
             if (!in_array($p['drafts_id'], $drafts_products)) {
                 $drafts_products[] = $p['drafts_id'];
             }
         }
     } else {
         return false;
     }
     $rule1 = count($drafts_products) >= count($drafts);
     if (!$rule1) {
         return $rule1;
     }
     foreach ($products as $p) {
         $el_usage = $class_pm->retrieveElementsUsage($p['products_id']);
         $rule2 = count($el_usage) > 0;
         if (!$rule2) {
             return $rule2;
         }
     }
     foreach ($products as $p) {
         $pa = $class_pa->retrieveList($p['products_id']);
         foreach ($pa as $val) {
             $rule3 = $class_pa->haveOverridedElement($val['products_articles_id']);
             if (!$rule3) {
                 return $rule3;
             }
         }
     }
     foreach ($products as $p) {
         $qm = "SELECT is_main FROM products_use_elements WHERE is_main = '1'" . " AND products_id = '" . $p['products_id'] . "'";
         $qm_r = tep_db_query($qm);
         $rule4 = tep_db_num_rows($qm_r);
         if ($rule4 == 0) {
             return $rule4;
         }
     }
     return true;
 }
foreach ($products as $p) {
    $query_products_categories = "SELECT * FROM products_to_categories ptc WHERE products_id={$p['products_id']}";
    $tpdbq_products_categories = tep_db_query($query_products_categories);
    $products_categories = tep_db_fetch_array($tpdbq_products_categories);
    // find what use element in this product
    $ean_eu_collection[$p['products_id'] . '-0'] = '';
    $tpdbq_products_use_elements = $class_pm->retrieveElementsUsage($p[products_id]);
    foreach ($tpdbq_products_use_elements as $row_pue) {
        $use_elements[] = array('elements_id' => $row_pue['elements_id'], 'quantity' => (int) $row_pue['quantity'] * $eao);
        $ean_eu_collection[$p['products_id'] . '-0'] .= $row_pue['elements_id'] . ' x ' . $row_pue['quantity'] . '|';
    }
    $mepa = count($tpdbq_products_use_elements);
    if ($mepa > $max_el_per_article) {
        $max_el_per_article = $mepa;
    }
    $tpdbq_products_articles = $class_pa->retrieveList($p[products_id], "active_status='1'");
    foreach ($tpdbq_products_articles as $row_pa) {
        $ean_eu_collection[$p['products_id'] . '-' . $row_pa['products_articles_id']] = '';
        $tpdbq_products_articles_use_elements = $class_pm->retrieveElementsUsage($p[products_id], $row_pa['products_articles_id']);
        foreach ($tpdbq_products_articles_use_elements as $row_pue) {
            $use_elements[] = array('elements_id' => $row_pue['elements_id'], 'quantity' => (int) $row_pue['quantity'] * $eao);
            $ean_eu_collection[$p['products_id'] . '-' . $row_pa['products_articles_id']] .= $row_pue['elements_id'] . ' x ' . $row_pue['quantity'] . '|';
        }
        $mepa = count($tpdbq_products_articles_use_elements);
        if ($mepa > $max_el_per_article) {
            $max_el_per_article = $mepa;
        }
    }
    //$query_products_use_elements = "SELECT * FROM products_use_elements pue WHERE pue.products_id = $p[products_id]";
    //$tpdbq_products_use_elements = tep_db_query($query_products_use_elements);
    //switch ($products_categories['categories_id']) {
예제 #4
0
    $logger->write("Skipped! Not to be run in  Manobo Local");
} else {
    use_class('styles');
    use_class('products_minierp');
    use_class('products_articles');
    $class_s = new styles();
    $class_pm = new products_minierp();
    $class_pa = new products_articles();
    $style_id = 680;
    //COLLECTION: DOOMED TO BE KILLED
    $products = $class_s->retrieveProducts($style_id, false);
    $killed = array();
    $logger->write('Total products to check: ' . count($products));
    foreach ($products as $pid => $date_added) {
        //SET INACTIVE FOR DTK ARTICLES WHICH HAVE NO DEPOT STOCK
        $products_articles = $class_pa->retrieveList($pid);
        foreach ($products_articles as $pa) {
            $stock_article = $class_pm->stockRetrieve(WAREHOUSE_ID_PRODUCTS_HAMBURG, $pid, $pa['products_articles_id']);
            if ($stock_article == 0) {
                $class_pa->setActiveStatus($pa['products_articles_id'], 0);
            }
        }
        $stock = $class_pm->stockRetrieve(WAREHOUSE_ID_PRODUCTS_HAMBURG, $pid, '*');
        if ($stock == 0) {
            //KILL PRODUCT AND REMOVE IT FROM DTK COLLECTION
            $username = '******';
            $class_pm->killProduct($pid, $username);
            $class_s->remProduct($style_id, $pid, $username);
            $killed[] = $pid;
        }
    }
$content .= '<th rowspan="2">Product</th>';
$content .= '<th rowspan="2">Articles</th>';
$content .= '<th rowspan="2">Stock</th>';
$content .= '<th colspan="2">Acive Booking</th>';
$content .= '<th rowspan="2">Cache<br />Status</th>';
$content .= '</tr><tr>';
$content .= '<th>Query</th>';
$content .= '<th>Cache</th>';
$content .= '</tr></thead>';
$content .= '<tbody>';
$rowcount = 0;
foreach ($articles_result as $pid => $articles) {
    $rowcount++;
    $rowclass = $rowcount % 2 == 0 ? 'e' : 'o';
    $pdata = $class_pm->retrieveDetail($pid, 'p,pnc');
    $alist = $class_pa->retrieveList($pid);
    $adata = array();
    foreach ($alist as $al) {
        $adata[$al['products_articles_id']] = $al;
    }
    $content .= '<tr class="' . $rowclass . '">';
    $content .= '<td class="id">' . $rowcount . '</td>';
    $content .= '<td>';
    $content .= webImage($pdata['p']['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $pid);
    $content .= '<br /><a href="?open=product-detail&amp;products_id=' . $pid . '">' . $pid . '</a>';
    $content .= '</td>';
    $col_ean = '';
    $col_stock = '';
    $col_booked_query = '';
    $col_booked_cache = '';
    $cache_status = true;
 //P_CATEGORIES (USED SUB CATEGORY)
 //FROM PRODUCT DATA VALIDATION WE KNOW WE'LL ONLY HAVE 1 CATEGORY
 $xml_pcategories = $xmlt->drawTag($xml_product, 'P_CATEGORIES');
 foreach ($subcategory as $sc_id => $sc_name) {
     $xmlt->drawTag($xml_pcategories, 'P_CATEGORY', $sc_name, array('type' => 'cluster', 'identifier' => 'key', 'key' => 'pcat-' . $sc_id));
 }
 //ARTICLEDATA
 $article_counter = 0;
 $xml_articledata = $xmlt->drawTag($xml_product, 'ARTICLEDATA');
 //>>> MOTHER ARTICLES:
 //>>> - DEFAULT ARTICLE MOTHER
 $article_counter++;
 constructXMLArticle($xmlt, $parent_data, $article_counter, $xml_articledata);
 $products_uploaded[] = $pid;
 //>>> - ADDITIONAL ARTICLE MOTHER
 $additional_articles = $class_pa->retrieveList($pid);
 foreach ($additional_articles as $article) {
     if ($article['active_status'] == '1') {
         $article_counter++;
         constructXMLArticle($xmlt, $parent_data, $article_counter, $xml_articledata, $article);
     }
 }
 //>>> CHILDREN ARTICLES:
 if (is_array($products['c'])) {
     foreach ($products['c'] as $pid => $pdata) {
         //>>> - DEFAULT ARTICLE CHILDREN
         $article_counter++;
         constructXMLArticle($xmlt, $pdata, $article_counter, $xml_articledata);
         $products_uploaded[] = $pid;
         //>>> - ADDITIONAL ARTICLE CHILDREN
         $f_additional_articles = $class_pa->retrieveList($pid);
use_class('jng_sp_catalog');
$class_jc = new jng_sp_catalog();
use_class('products_articles');
$class_pa = new products_articles();
use_class('products_ean');
$class_ean = new products_ean();
$jng_sp_id = '1';
$products = $class_jc->retrieveCatalogForUpload($jng_sp_id);
$counter_p = 0;
$counter_a = 0;
foreach ($products as $p) {
    if ($p['products_ean'] == '') {
        $class_ean->attachToProduct($p['products_id']);
        $counter_p++;
    }
    $articles = $class_pa->retrieveList($p['products_id']);
    foreach ($articles as $a) {
        if ($a['length'] != $p['length']) {
            if ($a['products_ean'] == '') {
                $class_ean->attactToArticle($a['products_articles_id']);
                $counter_a++;
            }
        }
    }
    echo '.';
}
$content .= '<br />';
$content = "Total Products: {$counter_p}";
$content .= '<br />';
$content .= "Total Articles: {$counter_a}";
echo $content;
 /**
  * Generate family match key
  * @param Int $products_id
  * @param Int $articles_id
  * @return String
  */
 function refreshFamilyMatchKey($products_id, $articles_id = null)
 {
     //$group_ref_el_cat = array('casting', 'findings', 'handmade', 'chains', 'pearl');
     $group_ref_el_cat = $this->el_cat_searchkey;
     //Old Key formula : brand_id-categories_id-[el_id-qty] >> 13.12.10 changed to exclude brand_id
     //New Key formula : categories_id-[el_id-qty]
     use_class('element');
     use_class('products_minierp');
     use_class('products_articles');
     $class_pa = new products_articles();
     $class_pm = new products_minierp();
     if (is_null($products_id)) {
         $articles = $class_pa->retrieveDetail($articles_id);
         $products_id = $articles['products_id'];
     }
     $family_searchkey = '';
     $key1 = array();
     $key2 = array();
     $el_used = $class_pm->retrieveElementsUsage($products_id, $articles_id);
     if (count($el_used) > 0) {
         //$p_data = $class_pm->retrieveDetail($products_id, 'p,cat');
         $p_data = $class_pm->retrieveDetail($products_id, 'cat');
         //$key1[] = $p_data['p']['products_brand_id'];
         $key1[] = $p_data['categories_id'];
         foreach ($el_used as $dt) {
             $elid = $dt['elements_id'];
             $el = new element($elid);
             if (in_array($el->attributes['category']['id'], $group_ref_el_cat)) {
                 $key2[] = $elid;
                 $key2[] = $dt['quantity'];
             }
         }
         if (count($key2) > 0) {
             $family_searchkey = implode('-', array_merge($key1, $key2));
             if (is_null($articles_id)) {
                 tep_db_perform('products', array('family_searchkey' => $family_searchkey), 'update', "products_id={$products_id}");
                 //update also articles if exist
                 $articles = $class_pa->retrieveList($products_id);
                 foreach ($articles as $article) {
                     $articles_id = $article['products_articles_id'];
                     $this->refreshFamilyMatchKey($products_id, $articles_id);
                 }
             } else {
                 tep_db_perform('products_articles', array('family_searchkey' => $family_searchkey), 'update', "products_articles_id={$articles_id}");
             }
         }
     }
     return $family_searchkey;
 }
        $products = $class_pm->retrieveList("products_model='{$product_input}'");
        $products_total = count($products);
        switch (count($products)) {
            case 0:
                break;
            case 1:
                $pid = $products[0]['products_id'];
                break;
            default:
                $result['status'] = 'MOREFOUND';
        }
    }
}
if (!$cancel && $pid != 0) {
    $p = $class_pm->retrieveDetail($pid, 'p,pnc');
    $pa = $class_pa->retrieveList($pid);
    $products_image = webImageSource($p['p']['products_image'], '150', '150');
    $products_options = array();
    $default_length = $p['pnc']['products_length'] > 0 ? textLength($p['pnc']['products_length']) : '-';
    //    $products_options[] = $p['p']['products_ean'].','.$default_length;
    $products_options[] = '0;' . $p['p']['products_ean'] . ',' . $default_length;
    if ($default_length != '-') {
        //        foreach($pa as $a) $products_options[] = $a['products_ean'].','.textLength($a['length']);
        foreach ($pa as $a) {
            $products_options[] = $a['products_articles_id'] . ';' . $a['products_ean'] . ',' . textLength($a['length']);
        }
    }
    $bestgood_status = $class_pm->retrieveBestGoodStatus($pid);
    $result['status'] = 'FOUND';
    $result['products_id'] = $pid;
    $result['products_code'] = $p['p']['products_model'];
 $product_extra_images = array();
 $eanproblem = array();
 $nametoshort = array();
 $noname = array();
 $nodescription = array();
 $price20eur = array();
 $price0 = array();
 $navproblem = array();
 $imagesproblem = array();
 $imagesproblem2 = array();
 $navids = neckermannNavIDs();
 foreach ($products as $row) {
     if ($row['products_ean'] == '') {
         $eanproblem[] = $row['products_id'];
     }
     $product_articles[$row['products_id']] = $class_pa->retrieveList($row['products_id']);
     if (!in_array($row['products_id'], $eanproblem)) {
         foreach ($product_articles[$row['products_id']] as $pa) {
             if ($pa['products_ean'] == '') {
                 $eanproblem[] = $row['products_id'];
                 break 1;
             }
         }
     }
     if (strpos($row['name'], ' ') === false && strlen($row['name']) <= 10) {
         $nametoshort[] = $row['products_id'];
     }
     if ($row['name'] == '') {
         $noname[] = $row['products_id'];
     }
     if ($row['description'] == '') {
 $product_images = array();
 $eanproblem = array();
 $noname = array();
 $nodescription = array();
 $price20eur = array();
 $price0 = array();
 $navproblem = array();
 $imagesproblem = array();
 $imagesproblem2 = array();
 $colorproblem = array();
 //Get SP Navigations
 $navids = ottoDeNavIDs();
 foreach ($products as $rowcount => $row) {
     $pid = $row['products_id'];
     //Keep articles data as reference
     $product_articles[$pid] = $class_pa->retrieveList($pid);
     //Check if need to echo something (preventing browser timeout)
     if ($rowcount % $echo_steps == 0) {
         echo ". ";
     }
     //Check if EAN exist
     if ($row['products_ean'] == '') {
         $eanproblem[] = $pid;
     } else {
         foreach ($product_articles[$pid] as $pa) {
             if ($pa['products_ean'] == '') {
                 $eanproblem[] = $pid;
                 //since we only log per product
                 //there's no need to check other articles
                 //as soon as 1 article with no EAN is found
                 break 1;
예제 #12
0
    }
    $clist_template .= '<td class="' . $k . ' ui-corner-all">' . $value . '</td>';
}
$clist_template .= '</tr>';
$customers = $class_jc->retrieveList($jng_sp_id);
$customers_options = array();
foreach ($customers as $c) {
    $customers_options[$c['jng_sp_customers_id']] = "{$c['customer_firstname']} {$c['customer_lastname']}" . ($c['customer_title'] != '' ? " ({$c['customer_title']})" : '');
}
$customers_combo = '<select name="customer" class="input"><option value="0">Please choose...</option>' . loadComboListFromArray($customers_options) . '</select>';
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADPRODUCT') {
        $pid = tep_db_prepare_input($_POST['pid']);
        $rowclass = $_POST['rowclass'];
        $product = $class_pm->retrieveDetail($pid, 'p,pnc,pd');
        $articles = $class_pa->retrieveList($pid, "active_status='1'");
        $articles_options = array();
        $articles_options[] = '<div id="' . $pid . '-0-' . $product['p']['products_ean'] . '" class="article pointer" title="Click to toggle order for this article">' . 'EAN ' . $product['p']['products_ean'] . ($product['pnc']['products_length'] > 0 ? ' &sdot; ' . textLength($product['pnc']['products_length']) : '') . '</div>';
        foreach ($articles as $a) {
            $articles_options[] = '<div id="' . $pid . '-' . $a['products_articles_id'] . '-' . $a['products_ean'] . '" class="article pointer" title="Click to toggle order for this article">' . 'EAN ' . $a['products_ean'] . ' &sdot; ' . textLength($a['length']) . '</div>';
        }
        $product_image = webImage($product['p']['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $pid, '');
        $ajaxResult = array();
        $ajaxResult['pid'] = $pid;
        $ajaxResult['image'] = $product_image;
        $ajaxResult['desc'] = '<a href="?open=product-detail&amp;products_id=' . $pid . '" target="_blank" title="View / Manage Product Detail">' . $pid . ' / ' . $product['p']['products_model'] . '</a>';
        $ajaxResult['desc'] .= '<br />' . $product['pd']['2']['products_name'];
        $ajaxResult['arts'] = implode('', $articles_options);
        echo ajaxReturn($ajaxResult);
        exit;
    } elseif ($_POST['me_action'] == 'LOADCUSTADDRESS') {
예제 #13
0
    $result['ab'] = '<div class="article"><input id="bo-' . $pid . '-' . $aid . '" type="text" tabindex="' . $tabindex . '" class="bo number tgcalc" name="qty_booked" value="' . $booked . '" ' . $disabled . '/><div>';
    $tabindex++;
    $result['ap'] = '<div class="article"><input id="pp-' . $pid . '-' . $aid . '" type="text" tabindex="' . $tabindex . '" class="pp number tgcalc" name="qty_preproduce" value="' . $preproduce . '" ' . $disabled . '/><div>';
    $tabindex++;
    $result['ad'] = '<div class="article"><input id="od-' . $pid . '-' . $aid . '" type="text" tabindex="' . $tabindex . '" class="od number tgcalc" name="qty_ondemand" value="' . $ondemand . '" ' . $disabled . '/><div>';
    $tabindex++;
    $result['rt'] = is_null($realtotal) ? '' : '<div class="article rto">' . $realtotal . '</div>';
    $result['rd'] = is_null($realondemand) ? '' : '<div class="article rod">' . $realondemand . '</div>';
    return $result;
}
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADPRODUCT') {
        $pid = tep_db_prepare_input($_POST['pid']);
        $rowclass = $_POST['rowclass'];
        $product = $class_pm->retrieveDetail($pid, 'p,pnc,pd');
        $articles = $class_pa->retrieveList($pid);
        $articles_options = array();
        $articles_stock = array();
        $articles_report = array();
        $articles_book = array();
        $articles_preprod = array();
        $articles_ondemand = array();
        $aline = drawArticleLine($pid, '0', '1', $product['p']['products_ean'], $product['pnc']['products_length']);
        $articles_options[] = $aline['ao'];
        $articles_stock[] = $aline['as'];
        $articles_report[] = $aline['ar'];
        $articles_book[] = $aline['ab'];
        $articles_preprod[] = $aline['ap'];
        $articles_ondemand[] = $aline['ad'];
        foreach ($articles as $a) {
            $aline = drawArticleLine($pid, $a['products_articles_id'], $a['active_status'], $a['products_ean'], $a['length']);
예제 #14
0
 function templateElementsUsed($submit_action = '')
 {
     $products_id = isset($_POST['products_id']) ? $_POST['products_id'] : tep_db_prepare_input($_GET['products_id']);
     $act = isset($_POST['act']) ? $_POST['act'] : tep_db_prepare_input($_GET['act']);
     switch ($act) {
         case 'UPDATE_MATEXP_MANUAL':
             $matexp = tep_db_prepare_input($_POST['new_matexp']);
             $p = new Product($products_id);
             $p->updateMaterialExpense($matexp);
             $result = $matexp;
             break;
         case 'LOAD':
             $product = $this->retrieveDetail($products_id, 'p,pnc,pc');
             $p = $product['p'];
             $pc = $product['pc'];
             $pnc = $product['pnc'];
             $result = '';
             //ELEMENTS USED
             if ($pc !== false) {
                 //For Customized Products:
                 //CHECK FOR IMAGES OF CUSTOMIZED ELEMENTS
                 $pe_image = array();
                 $pci_query = "SELECT phe.elements_id, pci.*";
                 $pci_query .= " FROM products_has_elements phe";
                 $pci_query .= " INNER JOIN phe_custom_image pci ON pci.products_has_elements_id=phe.products_has_elements_id";
                 $pci_query .= " WHERE phe.products_id={$products_id}";
                 $pci_query .= " ORDER BY orientation ASC, position ASC";
                 $pci_result = tep_db_query($pci_query);
                 if (tep_db_num_rows($pci_result) > 0) {
                     while ($row = tep_db_fetch_array($pci_result)) {
                         if (!isset($pe_image[$row['elements_id']])) {
                             $pe_image[$row['elements_id']] = array();
                         }
                         $pe_image[$row['elements_id']][] = '<a href="?open=pe-uploaded-image&amp;id=' . $row['elements_custom_image_uploaded_id'] . '&amp;hidemenu=true" class="view_webpage" title="View uploaded image and comment">Image</a>';
                     }
                 }
                 //CHECK FOR TEXT OF CUSTOMIZED ELEMENTS
                 $pe_text = array();
                 $pct_query = "SELECT phe.elements_id, pct.*";
                 $pct_query .= " FROM products_has_elements phe";
                 $pct_query .= " INNER JOIN phe_custom_text pct ON pct.products_has_elements_id=phe.products_has_elements_id";
                 $pct_query .= " WHERE phe.products_id={$products_id}";
                 $pct_query .= " ORDER BY orientation ASC, position ASC";
                 $pct_result = tep_db_query($pct_query);
                 if (tep_db_num_rows($pct_result) > 0) {
                     $fulltext = array();
                     while ($textrow = tep_db_fetch_array($pct_result)) {
                         if (!isset($fulltext[$textrow['elements_id']])) {
                             $fulltext[$textrow['elements_id']] = array();
                         }
                         $fulltext[$textrow['elements_id']][] = $textrow['entry_text'];
                     }
                     foreach ($fulltext as $elements_id => $elements_text) {
                         $elements_fulltext = implode('\\n', $elements_text);
                         $pe_text[$elements_id] = '<a href="javascript:alert(\'' . $elements_fulltext . '\')">Text</a>';
                     }
                 }
                 //QUERY ELEMENTS
                 $phe_query = "SELECT phe.elements_id, COUNT(phe.elements_id) AS quantity, e.elements_code";
                 $phe_query .= ", ed.name, ei.image_path, ei.image_filename, (etes.elements_price/etes.pieces_per_qty_type) AS price, etes.price_currency";
                 $phe_query .= " FROM products_has_elements phe";
                 $phe_query .= " LEFT JOIN elements e ON e.elements_id=phe.elements_id";
                 $phe_query .= " LEFT JOIN elements_description ed ON ed.elements_id=e.elements_id AND ed.languages_id=1";
                 $phe_query .= " LEFT JOIN elements_images ei ON ei.elements_id=phe.elements_id AND elements_sample_name='EC1'";
                 $phe_query .= " LEFT JOIN elements_to_elements_suppliers etes ON etes.elements_id=phe.elements_id AND etes.is_default='1'";
                 $phe_query .= " WHERE phe.products_id={$products_id}";
                 $phe_query .= " GROUP BY phe.elements_id";
                 $phe_result = tep_db_query($phe_query);
                 if (tep_db_num_rows($phe_result) > 0) {
                     $result .= '<div class="draw-table">';
                     $result .= '<table class="el-used" border="0" cellpadding="0" cellspacing="0">';
                     //Header
                     $result .= '<tr><th>Image</th><th>ID</th>';
                     //$result .= '<th>Code</th>';
                     $result .= '<th>Info</th><th>Qty</th><th>Unit</th><th><abbr title="Material Expenses">Mat.Exp.</abbr></th></tr>';
                     $counter = 0;
                     while ($phe = tep_db_fetch_array($phe_result)) {
                         if ($phe['elements_code'] != '07-0001BS') {
                             $counter++;
                             $rowclass = $counter % 2 == 0 ? 'e' : 'o';
                             $qty_type = 'piece';
                             if ($phe['quantity'] > 1 && $qty_type == 'piece') {
                                 $qty_type .= 's';
                             }
                             $el_img = 'elements/' . $phe['image_path'] . $phe['image_filename'];
                             $el_img_src = webImageSource($el_img);
                             $el_img_link = '<a href="' . $el_img_src . '" class="view_image" title="Element ID ' . $phe['elements_id'] . '">';
                             $result .= '<tr class="' . $rowclass . '">';
                             $result .= '<td>' . $el_img_link . webImage($el_img, '80', '80') . '</a></td>';
                             $result .= '<td><strong>' . $phe['elements_id'] . '</strong></td>';
                             //$result .= '<td><strong>'.$phe['elements_code'].'</strong></td>';
                             $result .= '<td style="width:300px;text-align:left;">';
                             $result .= $phe['name'];
                             if (isset($pe_image[$phe['elements_id']]) || isset($pe_text[$phe['elements_id']])) {
                                 $result .= '<br /><br /><span class="red">Personized Elements:</span><br />';
                                 if (isset($pe_image[$phe['elements_id']])) {
                                     $result .= implode(' &bull; ', $pe_image[$phe['elements_id']]);
                                 }
                                 if (isset($pe_text[$phe['elements_id']])) {
                                     $result .= $pe_text[$phe['elements_id']];
                                 }
                             }
                             $result .= '</td>';
                             $result .= '<td>' . $phe['quantity'] . '</td>';
                             $result .= '<td>' . $qty_type . '</td>';
                             $result .= '<td style="text-align:right;"><a href="?open=elements-suppliers&id=' . $phe['elements_id'] . '&hidemenu=true" class="view_webpage" title="View elements suppliers detail">';
                             $matexp = calculateCurrency($phe['quantity'] * $phe['price'], $phe['price_currency']);
                             $result .= displayCurrency('EUR', $matexp);
                             $result .= '</a></td>';
                             $result .= '</tr>';
                         }
                     }
                     $result .= '</table>';
                     $result .= '</div>';
                 }
             } else {
                 //ELEMENTS USED
                 //For standard Products:
                 $result .= '<div id="add_el_used_form" style="display:none;">';
                 $submit_action = $submit_action == '' ? '?open=product-detail&amp;products_id=' . $products_id . '#prodet-tab2' : $submit_action;
                 $result .= '<form name="elements_used_add" action="' . $submit_action . '" method="post">';
                 $result .= '<input type="hidden" name="me_action" value="ELEMENTSUSEDADD" />';
                 $result .= '<input type="hidden" name="products_id" value="' . $products_id . '" />';
                 $result .= '<div class="form"><table border="0" cellpadding="0" cellspacing="0">';
                 $result .= '<tr><td class="label">Element ID/Code</td><td><input type="text" name="add_id" value="" /></td>';
                 $result .= '<tr><td>Element Qty</td><td><input type="text" name="add_qty" value="1" onfocus="$(this).select();" /></td>';
                 $result .= '</table></div>';
                 $result .= '<div class="buttons"><input type="submit" name="submit" value="Add Element" /></div>';
                 $result .= '</form>';
                 $result .= '</div>';
                 //OVERRIDE FORMS
                 $result .= '<div id="ovr_el_used_form" style="display:none;">';
                 $result .= '<form name="elements_used_add" action="' . $submit_action . '" method="post">';
                 $result .= '<input type="hidden" name="me_action" value="ELEMENTSUSEDOVR" />';
                 $result .= '<input type="hidden" id="pid" name="products_id" value="' . $products_id . '" />';
                 $result .= '<input type="hidden" id="ovr_pean" name="ovr_pean" value=""/>';
                 $result .= '<input type="hidden" id="ovr_paid" name="ovr_paid" value=""/>';
                 $result .= '<input type="hidden" id="ovr_pueid" name="ovr_pueid" value=""/>';
                 $result .= '<input type="hidden" id="ovr_elid_def" name="ovr_elid_def" value=""/>';
                 $result .= '<input type="hidden" id="ovr_qty_def" name="ovr_qty_def" value=""/>';
                 $result .= '<input type="hidden" id="ovr_elid_old" name="ovr_elid_old" value=""/>';
                 $result .= '<input type="hidden" id="ovr_qty_old" name="ovr_qty_old" value=""/>';
                 $result .= '<input type="hidden" id="type" name="ovr_type" value=""/>';
                 $result .= '<div class="form"><table border="0" cellpadding="0" cellspacing="0">';
                 $result .= '<tr><td class="label">Element ID/Code</td><td><input type="text" id="ovr_id" name="ovr_id" value="" onfocus="$(this).select();" /></td>';
                 $result .= '<tr><td>Element Qty</td><td><input type="text" id="ovr_qty" name="ovr_qty" value="1" onfocus="$(this).select();" /></td>';
                 $result .= '</table></div>';
                 $result .= '<div class="buttons"><input type="button" class="submit" value="Override Element" /></div>';
                 $result .= '</form>';
                 $result .= '</div>';
                 //QUESTION FORMS
                 $result .= '<div id="confirm_form" style="display:none;">';
                 $result .= '<div class="form"><table border="0" cellpadding="0" cellspacing="0">';
                 $result .= '<tr><td>There element ID overridden on Additional Lengths, do you want to also replace with element <span id="el_id" class="bold"></span>?</td></tr>';
                 $result .= '</table></div>';
                 $result .= '<div class="buttons"><button name="act_yes" id="act_yes">Yes</button><button name="act_no" id="act_no">No</button></div>';
                 $result .= '</div>';
                 $form_width = 845;
                 $result .= '<form name="elements_used_update" action="' . $submit_action . '" method="post">';
                 $result .= '<input type="hidden" name="me_action" value="ELEMENTSUSEDUPDATE" />';
                 $result .= '<input type="hidden" name="products_id" value="' . $products_id . '" />';
                 if ($elements_use_msg != '') {
                     $result .= '<div style="margin:10px 0px;font-weight:bold;" class="red">' . $elements_use_msg . '</div>';
                 }
                 $pue_query = "SELECT pue.*, e.elements_code, e.elements_name, e.elements_image, e.elements_price, e.stars, e.elements_description";
                 $pue_query .= " FROM products_use_elements pue";
                 $pue_query .= " LEFT JOIN element e ON e.elements_id=pue.elements_id";
                 //$pue_query .= " LEFT JOIN `products_non_configurator` pnc ON pue.`products_id` = pnc.`products_id`";
                 //$pue_query .= " LEFT JOIN elements e ON e.elements_id=pue.elements_id";
                 //$pue_query .= " LEFT JOIN elements_description ed ON ed.elements_id=e.elements_id AND ed.languages_id=1";
                 //$pue_query .= " LEFT JOIN elements_images ei ON ei.elements_id=pue.elements_id AND elements_sample_name='EC1'";
                 //$pue_query .= " LEFT JOIN elements_to_elements_suppliers etes ON etes.elements_id=pue.elements_id AND etes.is_default='1'";
                 $pue_query .= " WHERE pue.products_id={$products_id}";
                 $pue_query .= " GROUP BY pue.elements_id";
                 $pue_result = tep_db_query($pue_query);
                 $products_length = $pnc['products_length'];
                 $form_footer = '<div class="pro-button" style="width:' . ($form_width + 5) . 'px;">';
                 $form_footer .= '<a href="?open=products-add-elements&amp;pid=' . $products_id . '&amp;hidemenu=true" class="view_webpage"></a>';
                 $form_footer .= '<input type="button" id="add_el_used" value="Add Element" />';
                 $form_footer .= '<input type="submit" name="submit" value="Save Changes" {BTNUPDDIS} />';
                 $form_footer .= '</div>';
                 $form_footer .= '</form>';
                 if (tep_db_num_rows($pue_result) == 0) {
                     //No Elements attached to product
                     $dis = SERVER_IS_LOCAL ? ' disabled="disabled"' : '';
                     $dis_note = SERVER_IS_LOCAL ? '<br /><span class="smallText notice">* can only' . ' be updated in Manobo Central!</span>' : '';
                     $result .= '<div class="box w500" style="margin-bottom:20px;">' . 'Material Expense (set manually in ' . CURRENCY_CODE_EURO . '): &nbsp; <input type="text"' . ' id="p-matexp-manual" class="w080 tar" value="' . $p['material_expenses'] . '"' . $dis . ' />' . $dis_note . '</div>';
                     $result .= '<h3 class="red bold">No Element is attached to this product</h3>';
                     $result .= str_replace('{BTNUPDDIS}', 'disabled="disabled"', $form_footer);
                 } else {
                     $complexity_manual = array_keys(productComplexityName(null, 2));
                     $title_complexity = 'This complexity sets ';
                     $title_complexity .= '<strong>' . (in_array($p['complexity'], $complexity_manual) ? 'manually by user' : 'automatically by manobo') . '</strong>';
                     $title_complexity .= ', if you need to change this,<br/>please do as explained below:<ol><li>Click on complexity</li><li>Select new complexity from displayed list</li></ol>Done, should be complexity will updated to the new values';
                     $complexity = drawIconInfo($title_complexity, true, 'float-left', 'margin-right:5px;') . '<span id="elused-complexity" class="pointer" title="Click to set complexity manually">' . productComplexityName($p['complexity']) . '</span><select id="elused-complexity-manual" style="display:none;"><option value="">Please select complexity</option>' . loadComboListFromArray(productComplexityName(null, 2)) . '</select> Complexity &laquo;';
                     $deflength = $products_length <= 0 ? '&nbsp;' : '&raquo; Default Length ' . textLength($products_length);
                     $result .= '<div style="margin-top:10px;width:' . $form_width . 'px;"><h2 style="float:right;">' . $complexity . '</h2><h2>' . $deflength . '</h2></div>';
                     $result .= '<div class="smallText notice" style="margin-bottom:2px;">* Remove elements by updating Qty to 0 (zero). To save all changes you MUST click on button "Save Changes"</div>';
                     $result .= '<div class="draw-table">';
                     $result .= '<table class="proman" border="0" cellpadding="0" cellspacing="0">';
                     //Header
                     $result .= '<tr>';
                     $result .= '<th>Image</th><th>ID</th><th class="w100">Main&nbsp;Element<br> <a href="javascript:void(0)" id="clear-main-image">Clear</a></th>';
                     $result .= '<th>Name</th><th>Qty</th>';
                     $result .= '<th>Finishing</th>';
                     $result .= '<th><abbr title="Material Expenses">Mat.Exp.</abbr></th>';
                     $result .= '<th>Action</th>';
                     $result .= '</tr>';
                     $counter = 0;
                     $matexp_total = 0;
                     while ($pue = tep_db_fetch_array($pue_result)) {
                         $products_analysis_link = '';
                         $counter++;
                         $rowclass = $counter % 2 == 0 ? 'e' : 'o';
                         $pueid = $pue['products_use_elements_id'];
                         $elid = $pue['elements_id'];
                         $qty = $pue['quantity'];
                         $is_main_el = $pue['is_main'];
                         $lr_check = $pue['length_relevance'] == '1' ? 'checked="checked"' : '';
                         $is_main_el_check = $pue['is_main'] == '1' ? 'checked="checked"' : '';
                         $is_main_el_result = '<input type="radio" id="' . $elid . '" class="is_main" name="is_main[' . $pue['elements_id'] . ']" value="1"' . $is_main_el_check . '/>';
                         $el_img = webImageWithDetailLink($pue['elements_image'], '80', '80', 'Element ' . $pue['elements_id']);
                         $quantity = '<input type="text" name="upd_qty[' . $pue['elements_id'] . ']" value="' . $pue['quantity'] . '" style="width:50px;text-align:center;" onfocus="this.select();" />';
                         $fin_gp = $pue['finishing_goldplate'] == '1' ? 'checked="checked"' : '';
                         $fin_hm = $pue['finishing_hammer'] == '1' ? 'checked="checked"' : '';
                         $fin_br = $pue['finishing_brush'] == '1' ? 'checked="checked"' : '';
                         $fin_ox = $pue['finishing_oxid'] == '1' ? 'checked="checked"' : '';
                         $fin_rg = $pue['finishing_rosegoldplate'] == '1' ? 'checked="checked"' : '';
                         $finishing = '<div style="margin-left:15px;"><table border="0" cellpadding="0" cellspacing="0">';
                         $finishing .= '<tr><td style="width:20px;"><input type="checkbox" id="fin_gp_' . $counter . '" class="fin" name="finishing_goldplate[' . $pue['elements_id'] . ']" value="1"' . $fin_gp . ' /></td><td class="load"><label for="fin_gp_' . $counter . '">Yellow Goldplate</label></td></tr>';
                         $finishing .= '<tr><td style="width:20px;"><input type="checkbox" id="fin_rg_' . $counter . '" class="fin" name="finishing_rosegoldplate[' . $pue['elements_id'] . ']" value="1"' . $fin_rg . ' /></td><td class="load"><label for="fin_rg_' . $counter . '">Rose Goldplate</label></td></tr>';
                         $finishing .= '<tr><td style="width:20px;"><input type="checkbox" id="fin_hm_' . $counter . '" class="fin" name="finishing_hammer[' . $pue['elements_id'] . ']" value="1"' . $fin_hm . ' /></td><td class="load"><label for="fin_hm_' . $counter . '">Hammer</label></td></tr>';
                         $finishing .= '<tr><td style="width:20px;"><input type="checkbox" id="fin_br_' . $counter . '" class="fin" name="finishing_brush[' . $pue['elements_id'] . ']" value="1"' . $fin_br . ' /></td><td class="load"><label for="fin_br_' . $counter . '">Brush</label></td></tr>';
                         $finishing .= '<tr><td style="width:20px;"><input type="checkbox" id="fin_ox_' . $counter . '" class="fin" name="finishing_oxid[' . $pue['elements_id'] . ']" value="1"' . $fin_ox . ' /></td><td class="load"><label for="fin_ox_' . $counter . '">Oxid</label></td></tr>';
                         $finishing .= '</table></div>';
                         //$matexp = $pue['quantity'] * $pue['elements_price'];
                         $matexp = $this->elementMaterialExpenses($pue['quantity'], $pue['elements_price']);
                         if ($pue['finishing_goldplate'] == '1') {
                             $matexp += FINISHING_PRICE_YELLOWGOLD;
                         }
                         if ($pue['finishing_hammer'] == '1') {
                             $matexp += FINISHING_PRICE_HAMMER;
                         }
                         if ($pue['finishing_brush'] == '1') {
                             $matexp += FINISHING_PRICE_BRUSH;
                         }
                         if ($pue['finishing_oxid'] == '1') {
                             $matexp += FINISHING_PRICE_OXID;
                         }
                         if ($pue['finishing_rosegoldplate'] == '1') {
                             $matexp += FINISHING_PRICE_ROSEGOLD;
                         }
                         $matexp_total += $matexp;
                         $matexp_link = '<a href="?open=elements-suppliers&id=' . $pue['elements_id'] . '&hidemenu=true" class="view_webpage" title="View elements suppliers detail">' . displayCurrency('EUR', $matexp) . '</a>';
                         //$products_analysis_link = '<a href="?open=products-analysis&sp=allsp&filter=el-used&sign=e&value='.$pue['elements_id'].'" target="_blank">Show all Products using this element</a>';
                         $products_analysis_link = '<a href="?open=products-analysis&sp=allsp&filter=el-used&sign=e&value=' . $pue['elements_id'] . '" target="_blank" title="Show all Products using Element ' . $pue['elements_id'] . '">&laquo; Show All Products &raquo;</a>';
                         $result .= '<tr class="' . $rowclass . '">';
                         $result .= '<td>' . $el_img . '</td>';
                         $result .= '<td><a class="view_webpage" href="?open=element&amp;id=' . $pue['elements_id'] . '&amp;hidemenu=true" title="Manage Element Detail">' . $pue['elements_id'] . '</a></td>';
                         $result .= '<td>' . $is_main_el_result . '</td>';
                         $result .= '<td class="name">' . $pue['elements_description'] . '<br />' . drawStars($pue['stars']) . '<br />' . $products_analysis_link . '</td>';
                         $result .= '<td>' . $quantity . '</td>';
                         $result .= '<td style="width:120;">' . $finishing . '</td>';
                         $result .= '<td class="pri">' . $matexp_link . '</td>';
                         $btn_o_def = '<input class="btn_ovr_def" type="button" value="Replace" title="Replace this element" />';
                         $h_pueid = '<input type="hidden" id="d_pueid" value="' . $pueid . '"/>';
                         $h_elid_def = '<input type="hidden" id="d_elid" value="' . $elid . '"/>';
                         $h_qty_def = '<input type="hidden" id="d_qty" value="' . $qty . '"/>';
                         $result .= '<td>' . $btn_o_def . $h_pueid . $h_elid_def . $h_qty_def . '</td>';
                         $result .= '</tr>';
                     }
                     $products_finishing = array();
                     $products_finishing_styles = $this->productHaveStylePrice('PF', $products_id);
                     $products_finishing_cost = 0;
                     if (count($products_finishing_styles) > 0) {
                         foreach ($products_finishing_styles as $styles_id) {
                             $products_finishing_cost = $this->getStylePrice($styles_id);
                             $matexp_total += $products_finishing_cost;
                             //not use class styles related to php5 issues for J&G webshop
                             $f_r = tep_db_query("SELECT name FROM styles_description WHERE styles_id = {$styles_id} AND languages_id = 2");
                             $f_row = tep_db_fetch_array($f_r);
                             $products_finishing[$f_row['name']] = $products_finishing_cost;
                         }
                     }
                     //$result .= '<tr><td colspan=""></td></tr>';
                     $result .= '</table></div>';
                     $chk_partial_plated = $product['p']['is_partial_plated'] == '1' ? 'checked="checked"' : '';
                     $title_product_is_partial_plated = 'Check this when product plated partially';
                     $result .= '<div style="margin:10px 0;float:left;" title="' . $title_product_is_partial_plated . '"><input type="checkbox" id="is_pp" value="1" name="is_partial_plated" ' . $chk_partial_plated . '>' . '<label for="is_pp"> Product is Partially Plated</label></div>';
                     if (count($products_finishing) > 0) {
                         $result .= '<div style="margin:10px 0;width:' . $form_width . 'px;text-align:right;">';
                         foreach ($products_finishing as $pfin_name => $pfin_cost) {
                             $result .= 'Product Finishing ' . $pfin_name . ': ' . displayCurrency('EUR', $pfin_cost) . '<br/>';
                         }
                         $result .= '</div>';
                     }
                     $result .= '<h3 style="margin:10px 0;width:' . $form_width . 'px;text-align:right;">Total Material Expenses: ' . displayCurrency('EUR', $matexp_total) . '</h3>';
                     $result .= str_replace('{BTNUPDDIS}', '', $form_footer);
                     //ARTICLES (ADDITIONAL LENGTH) TABLES
                     use_class('products_articles');
                     $class_pa = new products_articles();
                     $articles = $class_pa->retrieveList($products_id);
                     if (count($articles) > 0) {
                         $result .= '<div style="margin-top:30px;"><h2>Additional Length</h2></div>';
                         foreach ($articles as $key => $article) {
                             $p_aid = $article['products_articles_id'];
                             $qaue = "SELECT pa.*, pue.`quantity`,pue.`elements_id`, pue.`products_use_elements_id`, e.elements_image\n                                        FROM  products_articles pa\n                                        INNER JOIN `products_use_elements` pue ON pue.`products_id` = pa.`products_id`\n                                        LEFT JOIN element e ON e.`elements_id` = pue.`elements_id`\n                                        WHERE pa.`products_articles_id` = {$p_aid}";
                             $dbqaue = tep_db_query($qaue);
                             $p_ean = '';
                             $result .= '<div style="border:solid 1px #ababab;float:left;margin:0 20px 20px 0;background:#fff;">';
                             $articles_data = array();
                             while ($row = tep_db_fetch_array($dbqaue)) {
                                 $articles_data[$p_aid][] = $row;
                             }
                             foreach ($articles_data as $paid => $dt) {
                                 $p_ean = $dt[0]['products_ean'];
                                 $p_length = textLength($dt[0]['length']);
                                 $result .= '<h3 style="margin:5px;">Length ' . $p_length . '</h3>';
                                 $result .= '<table class="paid" border="0" celpadding="0" cellspacing="0"><tr><th>Image</th><th>ID</th><th>Qty.</th><th>Action</th></tr>';
                                 $n = 0;
                                 foreach ($dt as $key => $rd) {
                                     $el_img = $dt[$n]['elements_image'];
                                     $elid_def = $rd['elements_id'];
                                     $qty_def = $rd['quantity'];
                                     $qty_ovr = '0';
                                     $elid_ovr = '0';
                                     $pueid = $rd['products_use_elements_id'];
                                     $q_check = "SELECT paue.*, e.elements_image FROM products_articles_use_elements paue LEFT JOIN element e ON e.`elements_id` = paue.`elements_id` WHERE products_articles_id = {$p_aid} AND products_use_elements_id = {$pueid}";
                                     $dbqc = tep_db_query($q_check);
                                     if (tep_db_num_rows($dbqc) > 0) {
                                         while ($rc = tep_db_fetch_array($dbqc)) {
                                             $elid_ovr = $rc['elements_id'];
                                             $qty_ovr = $rc['quantity'];
                                             if ($elid_ovr != '' && $elid_ovr != '0') {
                                                 $el_img = $rc['elements_image'];
                                             }
                                         }
                                     }
                                     $style_elid = $elid_ovr != '0' && $elid_ovr != $elid_def ? ' bold' : '';
                                     $style_qty = $qty_ovr != '0' && $qty_ovr != $qty_def ? ' bold' : '';
                                     $elid = $elid_ovr != '0' ? $elid_ovr : $elid_def;
                                     $qty = $qty_ovr != '0' ? $qty_ovr : $qty_def;
                                     $result .= "<div>";
                                     $result .= '<tr id="' . $p_aid . $elid_def . '"' . ($style_elid != '' || $style_qty != '' ? 'style="background:#fbff96;"' : "") . ">";
                                     $result .= '<td class="img">' . webImage($el_img, '80', '80') . '</td>';
                                     $result .= '<td class="id' . $style_elid . '">' . ($style_elid != '' ? '<a href="?open=element&amp;id=' . $elid . '&amp;hidemenu=true" class="view_webpage">' . $elid . '</a>' : $elid) . '</td>';
                                     $result .= '<td class="qty' . $style_qty . '">' . $qty . '</td>';
                                     $h_paid = '<input type="hidden" id="h_paid" value="' . $p_aid . '"/>';
                                     $h_pean = '<input type="hidden" id="h_pean" value="' . $p_ean . '"/>';
                                     $h_pueid = '<input type="hidden" id="h_pueid" value="' . $pueid . '"/>';
                                     $h_elid_def = '<input type="hidden" id="h_elid_def" value="' . $elid_def . '"/>';
                                     $h_qty_def = '<input type="hidden" id="h_qty_def" value="' . $qty_def . '"/>';
                                     $h_elid = '<input type="hidden" id="h_elid" value="' . $elid . '"/>';
                                     $h_qty = '<input type="hidden" id="h_qty" value="' . $qty . '"/>';
                                     $btn_o = '<input class="btn_ovr" type="button" style="font-size:10;color:blue;margin:0;padding:0;" value="O" title="Override this element" />';
                                     $btn_r = $elid_ovr != 0 && $elid_ovr != $elid_def || $qty_ovr != 0 && $qty_ovr != $qty_def ? '<input class="btn_ovr_r" type="button" style="font-size:10;color:red;margin:0;padding:0;" value="R" title="Reset this element to ' . $elid_def . ' / ' . $qty_def . '"/>' : '<input class="btn_ovr_r" type="button" style="font-size:10;margin:0;padding:0;color:grey;" value="R" title="Reset this element to ' . $elid_def . ' / ' . $qty_def . '" disabled="disabled"/>';
                                     $result .= "<td>{$btn_o} {$btn_r} {$h_paid} {$h_pean} {$h_pueid} {$h_elid_def} {$h_qty_def} {$h_elid} {$h_qty}</td>";
                                     $result .= "</tr>";
                                     $n++;
                                 }
                                 $result .= '</table>';
                             }
                             $result .= '</div>';
                         }
                     }
                 }
                 $result .= '<div style="clear:both;"></div>';
             }
             $result = utf8_encode($result);
             break;
         case 'UPDATE':
             break;
         case 'ADD':
             break;
     }
     return $result;
 }