function postProcess($post_vars) { global $session_userinfo; $result = array(); if ($post_vars['me_action'] == 'SEARCH') { $type = $post_vars['type']; $jng_sp_id = $post_vars['jng_sp_id']; //another strange case, in live datepicker filter is always given as \'datevalue\' instead of 'datevalue' //still cant find the root cause (and it's ok in local dev), so for quickwin workaround we simple replace //the \' value into ' with below update (sahat 11.02.2014) //$post_filters = explode("|", $post_vars['post_filters']); $post_filters = explode("|", str_replace('\\\'', "'", $post_vars['post_filters'])); $filters = array(); foreach ($post_filters as $f) { $f_temp = explode('-', $f); $field = $f_temp[0]; unset($f_temp[0]); $value = implode('-', $f_temp); //explode to array for input on field $multivalue_fields which allowed multivalue separated by $multivalue_separator if (in_array($field, $this->multivalue_fields)) { $mv_temp = explode(current($this->multivalue_separator), $value); if (is_array($mv_temp) && $mv_temp > 0) { foreach ($mv_temp as $mv) { $mv = trim($mv); if (!isset($filters[$field]) || !in_array($mv, $filters[$field])) { $filters[$field][] = $mv; } } } else { $filters[$field][] = $value; } } else { $filters[$field][] = $value; } } $query = $this->constructQuery($jng_sp_id, $filters); $dbq = tep_db_query($query); $result = ''; $total = 0; $elements_ids = ''; //$display_spot = ''; while ($r = tep_db_fetch_array($dbq)) { $total++; if ($total > 1) { $elements_ids .= ','; } $elements_ids .= $r['elements_id']; // $display_spot .= '<div id="'.$r['elements_id'].'" class="lists-elements"></div>'; } $result['type'] = $type; $result['total'] = $total; $result['elements_ids'] = $elements_ids; // $result['display_spot'] = $display_spot; ajaxReturn($result); } elseif ($post_vars['me_action'] == 'DISPLAY') { $type = $post_vars['type']; $elements_id = $post_vars['elements_id']; $query = "SELECT e.elements_id, e.elements_code, e.elements_name, e.elements_image, e.elements_price, e.add_date, IFNULL(e.elements_weight,'-') elements_weight, e.stars, e.elements_description"; $query .= ", IFNULL(esup.suppliers_name,'-') suppliers_name"; $query .= ", el.used_in_products, IFNULL(el.weekly_sold, '-') weekly_sold, IFNULL(el.weekly_sold_products, '-') weekly_sold_products, IFNULL(el.sold_monthly_1, '-') last_month_sold"; $query .= ", (IFNULL(els.sold_{$this->last_year}_sp, 0) + IFNULL(els.sold_{$this->last_year}_jg, 0)) sold_{$this->last_year}"; $query .= ", (IFNULL(els.sold_products_{$this->last_year}_sp, 0) + IFNULL(els.sold_products_{$this->last_year}_jg, 0)) sold_products_{$this->last_year}"; $query .= ", ec.name AS cat_name, pm.material_name AS mat_name, cpd.name AS color_name, ei.name AS size_name, eh.name AS holesize_name"; $query .= ", es.name AS shape_name, es.shape_image, eu.name AS surface_name, eu.surface_image, et.name AS cut_name, et.cuts_image AS cut_image"; $query .= ", ehe.name AS height_name, ew.name AS width_name, eth.name AS thickness_name, est.stock"; $query .= ", DATEDIFF(NOW(), e.add_date) AS elements_age"; $query .= " FROM element e"; $query .= " LEFT JOIN elements_log el ON el.elements_id=e.elements_id"; $query .= " LEFT JOIN elements_log_static els ON els.elements_id=e.elements_id"; $query .= " LEFT JOIN elements_to_elements_suppliers etes ON etes.elements_id = e.elements_id AND is_default = 1"; $query .= " LEFT JOIN elements_suppliers esup ON esup.elements_suppliers_id = etes.elements_suppliers_id"; $query .= " LEFT JOIN elements_stock est ON est.elements_id = e.elements_id AND est.jng_warehouses_id = " . WAREHOUSE_ID_ELEMENTS; $query .= " LEFT JOIN element_category ec ON ec.element_category_id=e.attribute_category_id"; $query .= " LEFT JOIN products_materials pm ON pm.products_materials_id=e.attribute_material_id"; $query .= " LEFT JOIN color_pattern cp ON cp.color_pattern_id=e.attribute_color_id"; $query .= " LEFT JOIN color_pattern_description cpd ON cpd.color_pattern_id=e.attribute_color_id AND languages_id=1"; $query .= " LEFT JOIN element_size ei ON ei.element_size_id=e.attribute_size_id"; $query .= " LEFT JOIN element_holesize eh ON eh.element_holesize_id=e.attribute_holesize_id"; $query .= " LEFT JOIN element_shape es ON es.element_shape_id=e.attribute_shape_id"; $query .= " LEFT JOIN element_surface eu ON eu.element_surface_id=e.attribute_surface_id"; $query .= " LEFT JOIN element_cut et ON et.element_cut_id=e.attribute_cut_id"; $query .= " LEFT JOIN element_height ehe ON ehe.element_height_id=e.attribute_height_id"; $query .= " LEFT JOIN element_width ew ON ew.element_width_id=e.attribute_width_id"; $query .= " LEFT JOIN element_thickness eth ON eth.element_thickness_id=e.attribute_thickness_id"; $query .= " WHERE e.elements_id = '{$elements_id}'"; $dbq = tep_db_query($query); $res = tep_db_fetch_array($dbq); $elements_image = webImageWithDetailLink($res['elements_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Element ' . $res['elements_id'], 'img-border'); $elements_created = date('d-M-Y', strtotime($res['add_date'])); $elements_price = $res['elements_price'] < ELEMENTS_LOWER_PRICE ? displayCurrency('EUR', $res['elements_price'], true, 5) : displayCurrency('EUR', $res['elements_price']); $resultsdt = array(); //0-4 $resultsdt[] = $elements_id; $resultsdt[] = $elements_image; //$resultsdt[] = $res['elements_name']; $resultsdt[] = $res['elements_description']; $resultsdt[] = $elements_created; $resultsdt[] = $elements_price; //5-9 $resultsdt[] = $res['suppliers_name']; $resultsdt[] = $res['weekly_sold']; $resultsdt[] = $res['weekly_sold_products']; $resultsdt[] = $res['sold_' . $this->last_year]; $resultsdt[] = $res['sold_products_' . $this->last_year]; //10-14'd $resultsdt[] = $res['elements_weight']; $resultsdt[] = $res['last_month_sold']; $resultsdt[] = $res['stock']; $resultsdt[] = drawStars($res['stars']); $resultsdt[] = $res['elements_age']; $result['type'] = $type; $result['result'] = implode($this->result_separator, $resultsdt); ajaxReturn($result); } elseif ($post_vars['me_action'] == 'KILLELEMENT') { use_class('element'); $elid = tep_db_prepare_input($_POST['elid']); $element = new element($elid); $is_deleted = $element->delete($session_userinfo['username']); $result = array(); $result['target_id'] = $elid; $result['is_deleted'] = $is_deleted; ajaxReturn($result); } }
$content .= '<table border="0" cellpadding="0" cellspacing="0" class="form">'; $content .= '<tr><td>Element ID</td><td> </td><td><input type="text" id="di-elid" onfocus="$(this).select();" /><span class="red" style="margin-left:10px;">use comma "," separated for multi ID\'s</span></td></tr>'; $content .= '<tr><td>Qty</td><td> </td><td><input type="text" id="di-elqty" value="1" style="width:30px;text-align:center;" maxlength="3" onfocus="$(this).select();" /></td></tr>'; $content .= '<tr><td colspan="2"> </td>'; if ($is_accessed_from_design_mgmt) { use_class('design'); use_class('design_draft'); use_class('element'); $designs_id = isset($_GET['designs_id']) && $_GET['designs_id'] != '' ? $_GET['designs_id'] : ''; $draft = new design_draft(null, $_GET['pid']); $new_elements = $draft->retrieveElements(); if (count($new_elements) > 0) { $content .= '<tr><td>New Elements</td><td> </td><td>'; foreach ($new_elements as $ne) { $element = new element($ne['elements_id']); $content .= '<span id="' . $ne['elements_id'] . '" style="float:left;text-align:center;margin-right:5px;">' . webImageWithDetailLink($element->image, IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, $ne['elements_id'] . ' : ' . $ne['elements_name'], 'img-border') . '<br/>' . $ne['elements_id'] . ' <a class="pointer ne-add-el" title="Add this element to product">[+]</a></span>'; } $content .= '</td></tr>'; } } $content .= '<tr><td colspan="2"><input type="button" class="button blue" id="btn-di-add-el" value="Add Element" /></td></tr>'; $content .= '</table>'; $content .= '</div>'; //closed area-direct-input $content .= '<div id="area-search">'; $content .= $class_es->createFilterBox(false); $content .= $class_es->createResultBox(); $content .= '</div>'; //closed area-search $content .= '<div id="area-copy">'; $content .= '<table border="0" cellpadding="0" cellspacing="0" class="form">';
$content .= '<tr><td> » <abbr title="Total elements used (reduced from stock) in the Last 30 Days">L30D</title></td><td class="tar">' . $element->log['used_monthly_1'] . ' Qty</td></tr>'; $content .= '<tr><td> » <abbr title="Maximum usage in Active Products">Max/Product</abbr></td><td class="tar">' . $element->log['usage_max'] . ' Pcs</td></tr>'; $content .= '<tr><td colspan="2"> <a href="?open=element-forecasting&id=' . $element->id . '&hidemenu=true" class="view_webpage">» Forecasting</a></td></tr>'; $content .= '<tr><td colspan="2" class="bold">Sold Last 7 days</td></tr>'; $content .= '<tr><td> » Elements</td><td class="tar">' . $element->log['weekly_sold'] . ' Qty</td></tr>'; $content .= '<tr><td colspan="2" class="bold">Sold Last 30 days</td></tr>'; $content .= '<tr><td> » Elements</td><td class="tar">' . $element->log['sold_monthly_1'] . ' Qty</td></tr>'; $content .= '<tr><td> » Products</td><td class="tar">' . $element->log['sold_monthly_1_products'] . ' Pcs</td></tr>'; $last_year = date('Y') - 1; $content .= '<tr><td colspan="2" class="bold">Sold ' . $last_year . '</td></tr>'; $content .= '<tr><td> » Elements</td><td class="tar">' . $element->log['sold_' . $last_year] . ' Qty</td></tr>'; $content .= '<tr><td> » Products</td><td class="tar">' . $element->log['sold_products_' . $last_year] . ' Pcs</td></tr>'; $content .= '</table>'; $content .= '</div>'; $content .= '<div style="float:left;border:1px solid #ccc;margin-right:10px;text-align:center;width:130px;height:130px;">'; $content .= '<div>' . webImageWithDetailLink($element->image, '130', '130', 'Element ' . $element->id, 'elements_image') . '</div>'; $content .= '<div>' . drawStars($element->stars) . '</div>'; $content .= '</div>'; $content .= '<div>'; $content .= '<table class="form" border="0" cellpadding="0" cellspacing="0">'; $content .= '<tr><td width="80">' . $id_label . '</td><td colspan="2">' . $element_id . '</td></tr>'; $content .= '<tr><td>Name</td><td colspan="2">' . $element_name . '</td></tr>'; $content .= '<tr><td>Description</td><td colspan="2">' . $element_description . '</td></tr>'; $content .= '<tr><td>Weight</td><td>' . $element_weight . '</td><td class="notice">Gram</td></tr>'; $goldcarat_autoupdate_info = 'This field is auto updated when Element Attributes Material is filled<br/>as explained below:<ul><li>non-gold option: Material selected <strong>is not gold pure</strong></li><li>other carat option: Material selected <strong>is gold pure</strong></li></ul>'; $goldpureweight_autoupdate_info = 'This will auto calculated based on selected Gold Carat'; $content .= '<tr><td>Gold Carat</td><td>' . $goldpure_carat . '</td><td>' . drawIconInfo($goldcarat_autoupdate_info, true, 'float-right') . '<small style="float:right;" class="red">» auto update</small></td></tr>'; $content .= '<tr><td>Goldpure Weight</td><td>' . $element_weight_goldpure . '</td><td class="notice">Gram ' . drawIconInfo($goldpureweight_autoupdate_info, true, 'float-right') . '<small style="float:right;" class="red">» auto update</small></td></tr>'; $content .= '<tr><td>Supplier</td><td>' . $element_suppliers . '</td>'; $content .= '<td rowspan="2" width="200">'; if (is_null($element->id)) {
$dbq = tep_db_query($query); $total_rows = tep_db_num_rows($dbq); if ($total_rows > 0) { $table = array(); $t = array(); $t['o'] = 'Product Image'; $t['desc tac'] = 'Product Info'; $t['i'] = 'Elements Finishing'; $t['a'] = 'Action'; $table[] = $t; while ($r = tep_db_fetch_array($dbq)) { $products_id = $r['products_id']; //$productlink = '<br /><a href="?open=product-detail&products_id='.$products_id.'#prodet-tab2" class="view_webpage">'.$products_id.' / '.$r['products_model'].'</a>'; //$productlink = '<a href="?open=designs-products-elements-used&products_id='.$products_id.'&act=LOAD&hidemenu=true" class="view_webpage">'.$products_id.' / '.$r['products_model'].'</a>'; $productlink = '<a href="?open=product-detail&products_id=' . $products_id . '" target="_blank" title="Manage Product Detail">' . $products_id . ' / ' . $r['products_model'] . '</a>'; $t['o'] = webImageWithDetailLink($r['products_image'], IMAGE_SIZE_THUMBNAIL_2, IMAGE_SIZE_THUMBNAIL_2, 'Product ' . $products_id, 'img-border'); $info = array(); $info[] = $productlink . " ⋅ {$r['brand_name']}"; $info[] = ''; $info[] = '<strong>' . str_replace($goldplate_keyword, $goldplate_keyword_found, $r['products_name']) . '</strong>'; $info[] = '<span class="smallText notice">' . nl2br(str_replace($goldplate_keyword, $goldplate_keyword_found, $r['products_description'])) . '</span>'; $t['desc tac'] = implode('<br />', $info); $qe = "SELECT pue.*, e.elements_image FROM products_use_elements pue LEFT JOIN element e ON e.elements_id = pue.elements_id"; $qe .= " WHERE pue.products_id = '{$products_id}'"; $dbqe = tep_db_query($qe); $elements_used = ''; while ($re = tep_db_fetch_array($dbqe)) { $finishing = array(); $class = 'red'; if ($re['finishing_goldplate'] == '1') { $finishing[] = '<span class="green">Goldplate</span>';
$received = $r['quantity_received']; $sent = $r['quantity_sent']; // $t['q'] = $n; // $t['s'] = "$r[products_ean] ($r[type])"; $t['e'] = $r['received_date']; $t['o'] = $r['received_by']; $t['a'] = $r['received_status']; $table[] = $t; } $received_sent = "{$received} from {$sent}"; $post_result .= tep_draw_table('spo', $table); } else { $received_sent = ''; $post_result = '<h3 class="red">No receiving yet for this product</h3>'; } $p_img = webImageWithDetailLink($rp['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $products_id, 'img-border'); if ($received_sent != '') { $p_img .= '<br />' . $received_sent; } $post_result = '<div style="float:left;margin:0 10px 10px 0;">' . $p_img . '</div>' . $post_result; // $post_result .= '<br/><div style="text-align:center;"><input class="button simplemodal-close" type="button" value="Close" /></div>'; $ajaxResult = array(); $ajaxResult['result'] = $post_result; $ajaxResult['params'] = "{$ean};{$type}"; ajaxReturn($ajaxResult); exit; } elseif ($_POST['me_action'] == 'ADDAWB') { $package_id = $_POST['package_id']; $pcd = array(); $pcd['AWB'] .= isset($_POST['awb1']) && trim($_POST['awb1']) != '' ? $_POST['awb1'] : ''; $pcd['AWB'] .= isset($_POST['awb2']) && trim($_POST['awb2']) != '' ? $pcd['AWB'] != '' ? '; ' . $_POST['awb2'] : $_POST['awb2'] : '';
function imageButtons($image, $title, $no, $pei_id) { return '<div id="img-' . $no . '">' . webImageWithDetailLink($image, IMAGE_SIZE_THUMBNAIL_2, IMAGE_SIZE_THUMBNAIL_2, $title, 'img-border') . '</div>' . '<div id="dg-act-' . $no . '" class="dg-act">' . '<input type="hidden" name="imgno" value="' . $no . '"/>' . '<input type="hidden" name="pei_id" value="' . $pei_id . '" />' . '</div>'; }
$content .= '</div>'; use_class('products_search'); use_class('products_minierp'); $class_ps = new products_search(); $class_pm = new products_minierp(); if (isset($_POST['me_action'])) { if ($_POST['me_action'] == 'LOADROW') { $n = tep_db_prepare_input($_POST['n']); $ids = tep_db_prepare_input($_POST['ids']); $sp_id = tep_db_prepare_input($_POST['sp_id']); $pids = explode(',', $ids); $res = array(); $res = $class_ps->retrieveDataForDisplay($sp_id, $pids[0]); //echo "<pre>";var_dump($res);die(); $res = $res[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']);
function getDetailData($products_id, $type) { global $class_pm, $class_pa, $class_pb, $class_sp, $target_group, $colpats, $class_s; $result = array(); $detail_is_complete = false; $r_dt = ''; switch ($type) { case 'checkname': //NAME $r_nm = '<span class="red">Name not yet set</span>'; $nm = $class_pm->retrieveName($products_id, '2'); if ($nm != 'None') { $r_nm = "<span class=\"green\">{$nm}</span>"; } $r_dt .= "» {$r_nm}<br />"; //COLORS $colors = $class_pm->loadColorPatternNames($products_id, LANGUAGEID); $total_colors = count($colors); $colors_has_neon = false; if ($total_colors == 0) { $r_dt .= '» <span class="red">Color not yet set</span>'; } else { $r_cp = ''; foreach ($colors as $cpid => $cpname) { if ($cpid == '22') { $colors_has_neon = true; } $cp_img = webImageSource('color-pattern-' . $cpid . '.png'); $r_cp .= '<img src="' . $cp_img . '" width="20" height="20" title="' . $cpname . '" /> '; } $r_dt .= "» {$r_cp}"; if ($total_colors == 1 && !$colors_has_neon || $total_colors == 2 && $colors_has_neon) { $detail_is_complete = true; } else { $r_dt .= '<br /><strong class="red">Only 1 color / 2 colors with Neon is allowed!</strong>'; } } //$nm!='None' break; case 'setprofin': //optional step, auto set detail directly as complete $detail_is_complete = true; $styles = $class_s->getProductStyles($products_id); foreach ($styles as $groups => $styles_data) { if ($groups == ProductAttribute::GROUP_ID_PRODUCT_FINISHING) { $product_finishing = $styles_data; break; } } $total_profin = count($product_finishing); if ($total_profin == 0) { $r_profin = '» <span class="notice">' . 'No Product Finishing attached</span>'; } else { $r_profin = '» <span class="green">' . implode(', ', $product_finishing) . '</span>'; } $r_dt .= $r_profin; break; case 'setsubcat': $styles = $class_s->getProductStyles($products_id); $subcat = array(); //S now substracted as S1, S2, etc. so we couldn't use this anymore //foreach($styles['S'] as $sbk=>$sbv) $subcat[] = $sbv; foreach ($styles as $groups => $styles_data) { if ($groups[0] == ProductAttribute::GROUP_ID_SUB_CATEGORY) { foreach ($styles_data as $styles_id => $styles_name) { $subcat[] = $styles_name; } } } $total_subcat = count($subcat); $r_subcat = ''; if ($total_subcat == 0) { $r_subcat .= '» <span class="red">Sub Category not yet set</span>'; } elseif ($total_subcat > 1) { $r_subcat .= '» ' . implode('<br />» ', $subcat); $r_subcat .= '<br /><strong class="red">Only 1 Sub Category is allowed!</strong>'; } else { $r_subcat .= '» <span class="green">' . $subcat[0] . '</span>'; $detail_is_complete = true; } $r_dt .= $r_subcat; break; case 'setbrand': $product = $class_pm->retrieveDetail($products_id, 'p'); $r_br = '<span class="red">not yet set</span>'; if ($product['p']['products_brand_id'] != '' && $product['p']['products_brand_id'] != '0') { $brand = $class_pb->retrieveDetail($product['p']['products_brand_id']); $r_br = "<span class=\"green\">" . $brand['brand_name'] . "</span>"; $detail_is_complete = true; } $r_dt .= "» {$r_br}"; break; case 'setlength': $ln = ''; $r_ln = '<span class="red">not yet set</span>'; $product = $class_pm->retrieveDetail($products_id, 'p,pd,pnc'); $articles = $class_pa->retrieveList($products_id); if ($product['pnc']['products_length'] != '') { $ln = '<strong>' . textLength($product['pnc']['products_length']) . '</strong> (default)'; } if (isset($articles) && is_array($articles) && count($articles) > 0) { foreach ($articles as $a) { if ($ln != '') { $ln .= ', '; } //$ln .= number_format($a['length'], 1).' cm'; $ln .= textLength($a['length']); } } if ($ln != '') { $detail_is_complete = true; $r_ln = "<span class=\"green\">{$ln}</span>"; } $r_dt .= "» {$r_ln}"; break; case 'addelements': $r_el = '» <span class="red">not yet set</span>'; $el_used = $class_pm->retrieveElementsUsage($products_id); if (count($el_used) > 0) { $detail_is_complete = true; $r_el = "<span class=\"green\">"; $r_el .= '<table border="0" cellpadding="0" cellspacing="0" class="form">'; $els = array(); use_class('element'); foreach ($el_used as $el_id => $el_data) { $r_el .= "<tr>"; $e = new element($el_id); $el_image = webImageWithDetailLink($e->image, IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Element ' . $e->id, 'img-border'); $r_el .= '<td class="green" title="quantity"><strong>' . $el_data['quantity'] . 'x</strong></td>'; $r_el .= '<td class="green">' . $el_image . '</td>'; $r_el .= '<td class="green"><a class="green" href="?open=element&id=' . $el_id . '&hidemenu=true">' . $el_id . '</a></td>'; $r_el .= '<td class="green">' . $e->detail['name'] . '</td>'; $finishing = array(); if ($el_data['finishing_goldplate'] == '1') { $finishing[] = 'Yellow Goldplate'; } if ($el_data['finishing_hammer'] == '1') { $finishing[] = 'Hammer'; } if ($el_data['finishing_brush'] == '1') { $finishing[] = 'Brush'; } if ($el_data['finishing_oxid'] == '1') { $finishing[] = 'Oxid'; } if ($el_data['finishing_rosegoldplate'] == '1') { $finishing[] = 'Rose Goldplate'; } if (count($finishing) > 0) { $r_el .= '<td class="green" title="finishing">(' . implode(',', $finishing) . ')</td>'; } $r_el .= "</tr>"; } $r_el .= "</table>"; $r_el .= "</span>"; } $r_dt .= "{$r_el}"; break; case 'manpi': $r_mp = ''; //optional step, auto set detail directly as complete $detail_is_complete = true; $dbqmp = tep_db_query("SELECT * FROM products_non_configurator pnc WHERE pnc.products_id={$products_id}"); if (tep_db_num_rows($dbqmp) > 0) { $mpi = tep_db_fetch_array($dbqmp); // TODO: remove this after freetext switch to attach // $manpi = $mpi['products_instruction']; // if($manpi!='') $r_mp = "» <span class=\"green\">".substr($manpi, 0, 20)." ...</span>"; // End todo if (!empty($mpi['production_instruction_id'])) { $piids = explode(",", $mpi['production_instruction_id']); foreach ($piids as $piid) { $class_pim = new production_instruction_manual($piid); $r_mp .= "» <span class=\"green\">" . $class_pim->cat_name . " - " . $class_pim->name . "</span><br />"; } } } $r_dt .= $r_mp; break; case 'prolinks': $r_pr = ''; //optional step, auto set detail directly as complete $detail_is_complete = true; $dbqpl = tep_db_query("SELECT * FROM products_linking WHERE products_id={$products_id}"); if (tep_db_num_rows($dbqpl) > 0) { $r_pr = "<span class=\"green\">"; $pltype = array(); $plds = array(); while ($r = tep_db_fetch_array($dbqpl)) { $plds[$r['type']][] = $r['links_id']; } foreach (array_keys($plds) as $type) { foreach ($plds[$type] as $plid) { $plinks = $class_pm->retrieveDetail($plid, 'p'); $pl_image = webImage($plinks['p']['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $plid); $r_pr .= $pl_image . ' '; } } $r_pr .= "</span>"; } $r_dt .= $r_pr; break; case 'setnavs': $detail_is_complete = true; $dbq = tep_db_query("SELECT jng_sp_id, navigation, navigation2, navigation3 FROM jng_sp_catalog WHERE products_id={$products_id} ORDER BY jng_sp_id"); if (tep_db_num_rows($dbq) > 0) { $navlist = array(); while ($r = tep_db_fetch_array($dbq)) { $sp = $class_sp->retrieveDetail($r['jng_sp_id']); if ($sp['active_status'] == '1') { if ($r['jng_sp_id'] == '1') { if ($r['navigation2'] != '' && $r['navigation'] != '' && $r['navigation3'] != '' && $r['navigation3'] != '0') { $navlist[] = '» <span class="green"><strong>' . $sp['package_prefix'] . '</strong> [ all sets - Please Recheck ]</span>'; } else { $navlist[] = '» <span class="red"><strong>' . $sp['package_prefix'] . '</strong> [ not yet set or incomplete ]</span>'; $detail_is_complete = false; } } elseif ($r['jng_sp_id'] == '2') { if ($r['navigation'] != '' && $r['navigation3'] != '' && $r['navigation3'] != '0') { $navlist[] = '» <span class="green"><strong>' . $sp['package_prefix'] . '</strong> [ all sets - Please Recheck ]</span>'; } else { $navlist[] = '» <span class="red"><strong>' . $sp['package_prefix'] . '</strong> [ not yet set or incomplete ]</span>'; $detail_is_complete = false; } } elseif ($r['jng_sp_id'] == '3') { if ($r['navigation'] != '') { $navlist[] = '» <span class="green"><strong>' . $sp['package_prefix'] . '</strong> [ all sets - Please Recheck ]</span>'; } else { $navlist[] = '» <span class="red"><strong>' . $sp['package_prefix'] . '</strong> [ not yet set or incomplete ]</span>'; $detail_is_complete = false; } } } } } $r_dt = implode('<br />', $navlist); break; case 'setdesc2': $min_value_needed = 3; $p = $class_pm->retrieveDetail($products_id, 'p,pd2'); $pd2data = $class_pm->description2_label($p['pd2']); $total_pd2 = count($pd2data); // if($total_pd2>=$min_value_needed) $detail_is_complete = true; if ($p['p']['improved_content'] == '1') { $detail_is_complete = true; } // if($total_pd2 == 0) { if ($p['p']['improved_content'] == '0') { // $r_dt = '» <span class="red">No data has been set (min. '.$min_value_needed.')</span>'; $r_dt = '» <span class="red">Content Improved needs to be checked</span>'; } // else { // $r_dt = ''; // $r_dt_array = array(); // foreach($pd2data as $label=>$value) { // $data = $label.': '.$value; // if($detail_is_complete) $data = '<span class="green">'.$data.'</span>'; // $r_dt_array[] = '» '.$data; // } // $r_dt .= implode('<br />', $r_dt_array); //// if(!$detail_is_complete) $r_dt .= '<br /><strong class="red">Minimum '.$min_value_needed.' data must be set!</strong>'; // if(!$detail_is_complete) $r_dt .= '<br /><strong class="red">Content Improved needs to be checked</strong>'; // } break; case 'setfamily': $p = $class_pm->retrieveDetail($products_id, 'p'); if (is_null($p['p']['family_id'])) { $r_dt = '» <span class="red">Family Unset</span>'; } else { $detail_is_complete = true; $r_dt = '» <span class="green">Family ' . $p['p']['family_id'] . '</span>'; } break; } $result['view'] = utf8_encode('<div style="margin-left:10px;">' . $r_dt . '</div>'); $result['iscomplete'] = $detail_is_complete ? '1' : '0'; return $result; }
function drawLists($data, $type = '', $using_hide_button = false) { use_class("products_ean"); $class_pean = new products_ean(); $result = ''; if (count($data) > 0) { $h = array(); $table = array(); $result = ''; if ($using_hide_button) { $result .= '<input type="button" class="btn_hideorders" value="Hide Orders" style="position:absolute;margin:-28px 0 0 ' . ($type == 'D' ? '475' : '418') . 'px;" />'; } $result .= '<div class="draw-table" style="margin-bottom:20px;">'; $h['o'] = 'Products Info'; $h['a'] = 'Length'; $h['e'] = 'EAN'; if ($type == 'D') { $h['s'] = 'Qty Stock'; $h['q'] = 'Qty Actual'; } else { $h['s'] = 'Qty'; } $table[] = $h; foreach ($data as $key => $r) { $productlink = '<br /><a href="?open=product-detail&products_id=' . $r['products_id'] . '">' . "{$r['products_id']} / {$r['products_model']}" . '</a>'; $h['o'] = webImageWithDetailLink($r['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $r['products_id'], 'img-border') . $productlink; $ean_dt = $class_pean->getProductArticle($r['products_ean']); $h['a'] = textLength($ean_dt['length']); $h['e'] = $r['products_ean']; $h['s'] = $r['quantity_stock']; if ($type == 'D') { $h['q'] = $r['quantity_actual']; } elseif ($type == '') { if ($r['type'] == 'D') { $h['s'] = $r['quantity_actual']; } } $table[] = $h; } $result .= tep_draw_table("spo", $table); $result .= '</div>'; } else { $result = '<p class="red">No return from ' . ($type == 'R' ? 'orders' : 'depot') . '</p>'; } return $result; }
$t['name'] = 'Name'; $t['created'] = 'Created'; $t['weight'] = 'Weight'; $t['price'] = 'Price'; $t['supplier'] = 'Supplier'; $t['actualstock'] = 'Actual Stock'; $t['lastweeksold'] = 'Sold Last Week'; $t['lastmonthsold'] = 'Sold Last Month'; $t[$last_year . 'sold'] = 'Sold in ' . $last_year; $content .= '</tr>'; //$table[] = $t; $content .= printTableRow($t, 'o', true); $n = 0; while ($res = tep_db_fetch_array($dbq)) { $n++; $elements_image = webImageWithDetailLink($res['elements_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Element ' . $res['elements_id'], 'img-border'); $elements_price = displayCurrency('EUR', $res['elements_price']); $elements_created = date('d-M-Y', strtotime($res['add_date'])); $t['no'] = '<div>' . $n . '</div>'; $t['image'] = '<div>' . $elements_image . '</div>'; $t['id'] = '<div>' . $res['elements_id'] . '</div>'; $t['name'] = '<div>' . $res['elements_name'] . '</div>'; $t['created'] = '<div>' . $elements_created . '</div>'; $t['weight'] = '<div>' . $res['elements_weight'] . '</div>'; $t['price'] = '<div>' . $elements_price . '</div>'; $t['supplier'] = '<div>' . $res['suppliers_name'] . '</div>'; $t['actualstock'] = '<div>' . $res['elements_stock'] . '</div>'; $t['lastweeksold'] = '<div>' . $res['weekly_sold'] . '</div>'; $t['lastmonthsold'] = '<div>' . $res['last_month_sold'] . '</div>'; $t[$last_year . 'sold'] = '<div>' . $res['sold_' . $last_year] . '</div>'; $tr_class = $n % 2 == 0 ? 'e' : 'o';
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 />» 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 = ' '; } $cols[$hk] = $value; } $productrow = '<tr id="temp-' . $pid . '">'; foreach ($cols as $ck => $cv) { $productrow .= '<td class="' . $ck . '">' . $cv . '</td>'; } $productrow .= '</tr>'; return $productrow; }
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&id=' . $row['elements_custom_image_uploaded_id'] . '&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(' • ', $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&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&pid=' . $products_id . '&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 . '): <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 «'; $deflength = $products_length <= 0 ? ' ' : '» 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 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'] . '">« Show All Products »</a>'; $result .= '<tr class="' . $rowclass . '">'; $result .= '<td>' . $el_img . '</td>'; $result .= '<td><a class="view_webpage" href="?open=element&id=' . $pue['elements_id'] . '&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&id=' . $elid . '&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; }
use_class('products_minierp'); $class_pm = new products_minierp(); $content .= '<div id="prod-sales-info" style="margin-bottom:10px;">'; $content .= ' <div class="ui-state-default ui-corner-all" style="float:right;margin:10px 10px 0 0;">'; $content .= ' <span class="ui-icon ui-icon-minus" title="Hide/Show Sales Data" style="cursor: pointer;"></span>'; $content .= ' </div>'; $content .= ' <div class="ibox ui-corner-all">'; $npr = 0; foreach ($product_referer_ids as $product_referer_id) { $npr++; $content .= ' <h3>Product ' . $product_referer_id . ' Sales Data "All SP"</h3>'; $content .= ' <table border="0" cellpadding="0" cellspacing="0">'; $content .= ' <tr>'; $product_referer = $class_pm->retrieveDetail($product_referer_id, 'p,pl,sp'); $content .= ' <td align="center" rowspan="8">'; $content .= ' ' . webImageWithDetailLink($product_referer['p']['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $product_referer_id, 'img-border'); $content .= ' <br/>' . drawStars($product_referer['p']['stars']); $content .= ' </td>'; $content .= ' <td rowspan="8" width="10px;"> </td>'; $content .= ' <td>Age</td><td>= </td><td>' . intval($product_referer['sp']['0']['active_age']) . ' days</td>'; $content .= ' </tr>'; use_class('Product'); $obj_product = new Product($product_referer_id); $content .= '<tr><td>Products Sold</td><td>= </td><td>' . str_replace('align="center"', 'align="left"', $obj_product->displayRecentSoldTable()) . '</td></tr>'; // $content .= ' <tr><td>Sold Last 30 Days </td><td>= </td><td>'.intval($product_referer['pl']['sold_monthly_1']).'</td></tr>'; // $content .= ' <tr><td>Sold Last 60 Days </td><td>= </td><td>'.intval($product_referer['pl']['sold_monthly_2']).'</td></tr>'; // $content .= ' <tr><td>Sold Last 90 Days</td><td>= </td><td>'.intval($product_referer['pl']['sold_monthly_3']).'</td></tr>'; $content .= ' <tr><td>Total Sold</td><td>= </td><td>' . intval($product_referer['sp']['0']['total_sold']) . '</td></tr>'; $content .= ' <tr><td>Total Return</td><td>= </td><td>' . intval($product_referer['sp']['0']['total_returned']) . '</td></tr>'; $content .= ' <tr><td>Returns Rate</td><td>= </td><td>' . number_format($product_referer['sp']['0']['returned_rate'], 2) . '%</td></tr>'; $content .= ' <tr><td>Total Sales</td><td>= </td><td>' . displayCurrency('EUR', $product_referer['sp']['0']['total_sales']) . '</td></tr>';