예제 #1
0
function getTooltipThumbData($products_id, $articles_id, $jng_sp_id = '0')
{
    use_class('products_minierp');
    $class_pm = new products_minierp();
    $result = array();
    /* old method manual query
       $is_all_sp = ($jng_sp_id>0) ? false : true;
       $query = "SELECT pl.weekly_sold, pl.sold_monthly_1, pl.sold_monthly_2, pl.sold_monthly_3";
       $query .= ($is_all_sp)
           ? " , SUM(jc.total_sales) AS total_sales, SUM(jc.total_sold) AS total_sold, SUM(jc.total_returned) AS total_returned, (SUM(jc.total_returned)/SUM(jc.total_sold)) * 100 AS returned_rate, MAX(jc.active_age) AS active_age, 'All SP' AS package_prefix
               , AVG(jc.sales_weekly) AS sales_weekly, AVG(jc.sales_monthly) AS sales_monthly"
           : " , jc.total_sales, jc.total_sold, jc.returned_rate, jc.active_age, jsp.package_prefix
               , jc.sales_weekly, jc.sales_monthly";
       $query .= " FROM jng_sp_catalog jc ";
       $query .= " LEFT JOIN products_log pl ON pl.products_id=jc.products_id";
       if(!$is_all_sp) $query .= " LEFT JOIN jng_sp jsp ON jsp.jng_sp_id = $jng_sp_id";
       $query .= " WHERE jc.products_id = '$products_id'";
       if(!$is_all_sp) $query .= " AND jc.jng_sp_id = '$jng_sp_id'";
       if($is_all_sp) $query .= " GROUP BY jc.products_id";
       $dbq = tep_db_query($query);
       while($r = tep_db_fetch_array($dbq)){
           $result = $r;
       }
       */
    //TESTING NEW METHOD USING PRODUCTS MINIERP
    $pdata = $class_pm->retrieveDetail($products_id, 'pl,sp');
    if (isset($pdata['sp'][$jng_sp_id]) && is_array($pdata['sp'][$jng_sp_id])) {
        $result = array_merge($pdata['pl'], $pdata['sp'][$jng_sp_id]);
    } else {
        if ($jng_sp_id != '0') {
            //Special Case where we dont have the catalog info of the product in the selected SP
            //Usually for SP on which we can sell without uploading first the Catalog (products)
            $result = $pdata['pl'];
            //grab sp info
            $class_sp = new jng_sp();
            $sp_detail = $class_sp->retrieveDetail($jng_sp_id);
            //grab total orders and returns manually
            $q = "SELECT joi.products_id, SUM(joi.order_quantity) AS total_sold, SUM(joir.return_quantity) AS total_returns";
            $q .= " FROM jng_sp_orders jo";
            $q .= " INNER JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id AND joi.products_id={$products_id} AND joi.status NOT IN (10,12)";
            $q .= " LEFT JOIN jng_sp_orders_items_return joir ON joir.jng_sp_orders_items_id=joi.jng_sp_orders_items_id";
            $q .= " WHERE jo.jng_sp_id={$jng_sp_id}";
            $q .= " GROUP BY products_id";
            $r = tep_db_query($q);
            while ($row = tep_db_fetch_array($r)) {
                $result['package_prefix'] = $sp_detail['package_prefix'];
                $result['total_sold'] = $row['total_sold'];
                $result['returned_rate'] = $row['total_returns'] / $row['total_sold'] * 100;
                $result['active_age'] = '-1';
            }
        }
    }
    $result['products_stars'] = $class_pm->getDisplayStars($products_id);
    return $result;
}
예제 #2
0
$query .= " WHERE p.products_id IN (" . $pids . ") ORDER BY cat.categories_id";
$result = tep_db_query($query);
while ($row = tep_db_fetch_array($result)) {
    $cat[$row['categories_name']][] = array("id" => $row['products_id'], "image" => $row['products_image'], "price" => $row['products_price'], "price_old" => $row['products_price_old'], "model" => $row['products_model'], "stars" => $row['stars']);
}
foreach ($cat as $key => $value) {
    echo '<div style="clear:both;"></div>';
    $total_prods = 0;
    $total_disc = 0;
    $content = '<div style="margin:0 auto 20px auto;">';
    foreach ($value as $list) {
        $content .= '<div id="' . $list['id'] . '" style="float:left; border:solid 1px #ccc; text-align:center; margin:5px; background:#fff; width:170; height:250;" class="ui-corner-all">';
        $images = webImage($list['image'], 150, 150);
        $price = displayCurrency('EUR', $list['price']);
        $price_old = displayCurrency('EUR', $list['price_old']);
        $stars = $class_pm->getDisplayStars($list['id'], $list['stars']);
        $total_prods++;
        $content .= '<div>' . $images . '</div>';
        $content .= '<div>' . $stars . '</div>';
        $content .= '<div>' . $list['id'] . " / " . $list['model'] . '</div>';
        if ($price_old > 0) {
            $total_disc++;
            $content .= '<div class="notice deleted">' . $price_old . '</div>';
            $content .= '<div class="red">' . $price . '</div>';
        } else {
            $content .= '<div>' . $price . '</div>';
        }
        $content .= '</div>';
    }
    $title = '<div style="margin:10px;"><h2>' . $key . ' - ' . $total_disc . ' / ' . $total_prods . ' products is discounted.</h2></div>';
    $content .= '</div>';
function loadProductRow($pid, $pos, $curgroup_id)
{
    global $class_s, $header, $maxnav;
    use_class('products_minierp');
    $class_pm = new products_minierp();
    $product = $class_pm->retrieveDetail($pid, 'p,pl,sp');
    $cols = array();
    foreach ($header as $hk => $hv) {
        $value = '';
        switch ($hk) {
            case 'img':
                $value .= webImageAddPosition($pos, webImageWithDetailLink($product['p']['products_image'], IMAGE_SIZE_THUMBNAIL_2, IMAGE_SIZE_THUMBNAIL_2, "Product {$pid}"));
                break;
            case 'name':
                $value .= $pid . ' / ' . $product['p']['products_model'];
                $value .= '<br />' . $product['pd']['2']['products_name'];
                $value .= '<br />' . $class_pm->getDisplayStars('', $product['p']['stars']);
                $value .= '<br /><br />&raquo; Complexity = ' . productComplexityName($product['p']['complexity']);
                break;
            case 'age':
                $value .= $product['sp']['0']['active_age'] . '<br />days';
                break;
            case 'ts1':
                $value .= $product['sp']['0']['total_sold'];
                break;
            case 'ts2':
                $value .= displayCurrency('EUR', $product['sp']['0']['total_sales'], false);
                break;
            case 'ps':
                $value .= 'L30D=' . intval($product['pl']['sold_monthly_1']);
                $value .= '<br />L60D=' . intval($product['pl']['sold_monthly_2']);
                $value .= '<br />L90D=' . intval($product['pl']['sold_monthly_3']);
                break;
            case 'pspw':
                $value .= round($product['sp']['0']['sales_weekly'], 1);
                break;
            case 'pspm':
                $value .= round($product['sp']['0']['sales_monthly'], 1);
                break;
            case 'pb':
                use_class('products_brand');
                $value .= $product['p']['products_brand_name'];
                break;
            case 'cur':
                $attrs = $class_s->getProductStyles($pid);
                if (count($attrs[$curgroup_id]) > 0) {
                    foreach ($attrs[$curgroup_id] as $attr_id => $attr) {
                        $value .= drawAttribute($pid, $attr_id, $attr);
                    }
                }
                break;
            case 'act':
                $combo = array();
                for ($x = 1; $x <= $maxnav; $x++) {
                    $combo[] = '<select name="cmb-onebyone" class="input"></select>';
                }
                $value .= implode('<br />', $combo);
                $value .= '<br /><input type="button" class="input" name="save" value="Save" />';
        }
        if ($value == '') {
            $value = '&nbsp;';
        }
        $cols[$hk] = $value;
    }
    $productrow = '<tr id="temp-' . $pid . '">';
    foreach ($cols as $ck => $cv) {
        $productrow .= '<td class="' . $ck . '">' . $cv . '</td>';
    }
    $productrow .= '</tr>';
    return $productrow;
}
예제 #4
0
 $products_image = webImageWithDetailLink($res['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $pids[0], 'img-border');
 $products_price_old = displayCurrency('', $res['products_price_old']);
 $products_price = displayCurrency('', $res['products_price']);
 $discount = number_format($res['products_discount'], 2);
 $products_created = date('d-M-Y', strtotime($res['products_date_added']));
 $returned_rate = number_format($res['returned_rate'], 2);
 $total_sales = number_format($res['total_sales'], 2);
 $vc_now = number_format($res['vc_now'], 2);
 $total_vc = number_format($res['total_vc'], 2);
 $vc_percent = number_format($res['vc_percent'], 2);
 $margin = $res['margin'];
 $margin = '<span class="' . ($class_pm->priceMargindIsGood($res['products_price'], $margin) ? 'green' : 'red') . '">' . number_format($margin, 1) . '%</span>';
 $sales_monthly = number_format($res['sales_monthly'], 1);
 $sales_weekly = number_format($res['sales_weekly'], 1);
 $products_complexity = productComplexityName($res['complexity']);
 $products_stars = $class_pm->getDisplayStars('', $res['stars']);
 $t = array();
 $t['no'] = '<div>' . $n . '</div>';
 $t['image'] = '<div>' . $products_image . '</div>';
 $t['info'] = '<div><a href="?open=product-detail&products_id=' . $res['products_id'] . '" target="_blank">';
 $t['info'] .= $res['products_id'] . ' / ' . $res['products_model'] . '</a><br/>' . $res['products_name'] . '<br/>' . $products_stars . '<br/><br/>&raquo;&nbsp;';
 $hh_stock = $res['hh_stock'] > 0 ? $res['hh_stock'] : '0';
 $t['info'] .= '<strong class="' . ($res['hh_stock'] > 0 ? 'green' : '') . '">Depot HH Stock = ' . $hh_stock . '</strong>';
 $t['info'] .= '<br/>&raquo;&nbsp;Complexity = ' . $products_complexity . '</div>';
 $t['created'] = '<div>' . $products_created . '</div>';
 $t['priceold'] = '<div>' . $products_price_old . '</div>';
 $t['price'] = '<div>' . $products_price . '</div>';
 $t['disc'] = "<div>{$discount}%</div>";
 $t['vc'] = '<div>' . $vc_now . '</div>';
 $t['vcpct'] = "<div>{$vc_percent}%</div>";
 $t['margin'] = "<div>{$margin}" . '</div>';
    $c['psm'] = 'Qty. sold l.M.';
} else {
    $c['psw'] = 'Qty. sold p.W.';
    $c['psm'] = 'Qty. sold p.M.';
}
$c['l'] = 'Logo';
$c['act'] = 'Active';
$c['action'] = 'Action';
$cat[] = $c;
$logo_y = '<img id="%s" src="images/icon-yes.png" title="Click to hide logo for this product" />';
$logo_n = '<img id="%s" src="images/icon-no.png"  title="Click to show logo for this product" />';
while ($row = tep_db_fetch_array($cat_result)) {
    $detail_link = "?open=sp-product&amp;id={$row['products_id']}";
    $info = "<div><strong>{$row['products_id']} / {$row['article_number']}</strong></div>";
    $info .= "<div>{$row['name']}</div>";
    $info .= "<div>" . $class_pm->getDisplayStars('', $row['stars']) . "</div>";
    $price_old = $row['price_old'] > 0 ? $row['price_old'] : '-';
    //$age = countDuration($row['active_date'], 'now', 'day');
    $age = $row['active_age'] . ' day' . ($row['active_age'] > 1 ? 's' : '');
    $catalog_id = '<div style="display:none;" class="catalog" title="' . $row['jng_sp_catalog_id'] . '"></div>';
    $c = array();
    $c['img'] = '<div id="' . $row['jng_sp_catalog_id'] . '"><a href="' . $detail_link . '" title="View and Manage Product Detail for Neckermann Catalog">' . webImage($row['products_image'], '80', '80') . '</a></div>';
    $c['name'] = $info;
    $c['po'] = $price_old;
    $c['pr'] = $row['price'];
    $discount = $row['discount'] == 0 ? '-' : number_format($row['discount'], 2) . '%';
    $discstyle = $row['discount'] < 0 ? 'style="color:#f00;"' : '';
    $c['d'] = "<span {$discstyle} >{$discount}</span>";
    $c['mg'] = number_format($row['margin'], 1) . '%';
    $c['age'] = $age;
    $c['tpc'] = $row['total_sold'];