function addColor($color_pattern_id, $color_id) { //prepare parameter data & insert data $color_pattern_id = tep_db_prepare_input($color_pattern_id); if (is_array($color_id)) { foreach ($color_id as $c) { $c = tep_db_prepare_input($c); if (!is_dataExist("color_pattern_has_color", "color_pattern_id", "color_pattern_id={$color_pattern_id} AND color_id={$c}")) { $sql_data_array_cphc = array('color_pattern_id' => $color_pattern_id, 'color_id' => $c); $result_cphc[] = tep_db_perform('color_pattern_has_color', $sql_data_array_cphc); } else { $result_cphc[] = true; } } } else { $c = tep_db_prepare_input($color_id); if (!is_dataExist("color_pattern_has_color", "color_pattern_id", "color_pattern_id={$color_pattern_id} AND color_id={$c}")) { $sql_data_array_cphc = array('color_pattern_id' => $color_pattern_id, 'color_id' => $c); $result_cphc = tep_db_perform('color_pattern_has_color', $sql_data_array_cphc); } else { $result_cphc = true; } } return $this->parseReturn($result_cphc); }
function setDefaultSupplier($supplier_id, $supplier_price, $price_quantity_type, $price_currency, $pieces_per_qty_type, $resourcing_day) { $supplier = new elements_suppliers($supplier_id); $price = $pieces_per_qty_type > 0 ? calculateCurrency($supplier_price / $pieces_per_qty_type, $price_currency) : $supplier_price; //DISABLED THIS AND MOVED THIS FILTER WHEN CALCULATING MATERIAL EXPENSES (WILL APPLIED WHEN EL_PRICE * QTY < 0.01) //if($price<0.01) $price = ELEMENTS_LOWER_PRICE; //TO PREVENT PRICES LOWER THAN 0.01 (ex: 0.00817...) SAVED AS 0.00 $fn = array('elements_supplier', 'elements_price'); $fv = array($supplier->detail['name'], $price); $this->updateField($fn, $fv); $stock = array(); $stock['qty_type'] = $price_quantity_type; $stock['pieces_per_qty_type'] = $pieces_per_qty_type; $stock['resourcing_day'] = $resourcing_day; $default_warehouse_id = '1'; $exist_filter = "jng_warehouses_id={$default_warehouse_id} AND elements_id={$this->id}"; if (is_dataExist("elements_stock", "elements_id", $exist_filter)) { tep_db_perform('elements_stock', $stock, 'update', $exist_filter); } else { $stock['jng_warehouses_id'] = $default_warehouse_id; $stock['elements_id'] = $this->id; tep_db_perform('elements_stock', $stock); } /* Disabled this to avoid halted when updating suppliers data * TODO: This recalculation process is handled on separate cron or executed manually by user * Please remove above "TODO:" words if its already implemented recalcProductMaterialExpenses($this->id); * */ }