$result['piid'] = $piid; ajaxReturn($result); exit; } elseif ($_POST['me_action'] == 'PRODUCTSBRAND') { $products_id = tep_db_prepare_input($_GET['products_id']); $result = ''; switch ($_POST['act']) { case 'LOAD': $pc_query = tep_db_query("SELECT customers_id FROM products_configurator WHERE products_id={$products_id}"); $pc = tep_db_fetch_array($pc_query); if (isset($pc['customers_id']) && $pc['customers_id'] != '1') { $result .= '<h3 class="red">'; $result .= 'Sorry, you cannot set Brand to customers products'; $result .= '</h3>'; } else { $pbid = $class_pb->retrieveProductBrand($products_id); $brands = $class_pb->retrieveList(); $result .= '<div>'; if (count($brands) == 0) { $result .= '<h3>No Brand found in database</h3>'; } else { $table_columns = 2; $checked = 'checked="checked"'; $cl_sel = 'class="brand-sel"'; $result .= '<div style="margin:10px 0 20px 0;" class="sop-box ui-corner-all"> <h2>Important Notes</h2> » System will auto-save on clicking. <span class="green">Green underline</span> will move to new selected brand on successfull update. <br/>» Updating brand will be <span class="red">ignored/unsuccessfull</span> when this product already locked on a family, or family mother of this product is already locked. <br/>» Updating brand will also applied to other products which member of this Product Family. </div>'; $result .= '<table border="0" cellpadding="0" cellspacing="0">';
$q_dp .= " UNION"; } $q_dp .= " SELECT products_id, depot_orders_id orders_id, depot_orders_id items_id, '3' priority, 'NA' sp_id, 3 row_nr, 'DP' type"; $q_dp .= " FROM depot_orders"; $q_dp .= " WHERE status = 3"; $q_dp .= $mode == 'ready-printed-unscanned' ? " AND print_count > 0 AND print_confirmed = 0" : " AND print_count = 0"; $q_dp .= " AND NOT (trans_type='' AND trans_id=5)"; $q .= $q_dp; } $q .= " ) dt"; //$q .= " WHERE products_id != 72385"; $q .= " ORDER BY products_id, priority, row_nr, items_id"; $res = tep_db_query($q); while ($r = tep_db_fetch_array($res)) { $pid = $r['products_id']; $brand_id = $class_pb->retrieveProductBrand($pid); $type = $r['type']; $oid = $r['orders_id']; $oiid = $r['items_id']; $sp_id = $r['sp_id']; $is_prioritized = $r['priority'] == 1 || checkCustomerIsVIP($type, $oid) || in_array($sp_id, $sp_using_red_paper) || in_array($brand_id, $brand_using_red_paper); $key = "{$type}|{$oiid}"; $ok_print = false; if ($type == 'SP' || $type == 'JG') { /*Disabled this, since all orders that goes to ready will directly printed //ignore printing pdf for this order if there item that still on cancel request. $ok_print = (!orderItemHaveStatus($oid, 10, $type)); */ $ok_print = true; } elseif ($type == 'DP') { use_class('depot_orders');
/** * Add products to a family * @param Int $products_id * @return Boolean */ function addToFamily($products_id) { if (!is_array($products_id)) { $products_id = explode(',', $products_id); } if ($this->id != '') { use_class('products_minierp'); use_class('products_brand'); $class_pm = new products_minierp(); $class_pb = new products_brand(); $p_added = array(); //Avoid : //1) added product which color is same with product member of a family //2) added product which brand is different with family brand foreach ($products_id as $pid) { $cpids = $class_pm->loadColorPattern($pid); $new_product_brand_id = $class_pb->retrieveProductBrand($pid); $brand_ok = $new_product_brand_id == $this->brand_id; foreach ($cpids as $cpid) { if ($brand_ok && !in_array($cpid, $this->colors)) { $p_added[] = $pid; } } } if (count($p_added) > 0) { tep_db_query("UPDATE products SET family_id = '" . $this->id . "' WHERE products_id IN (" . implode(',', $p_added) . ")"); $this->recalcTotalMembers(); return true; } } return false; }