Example #1
0
function createExceptionFile($itemKeyValues)
{
    global $exceptionDir, $isMappingHeaderAdded, $itemMasterFields, $itemDistributorFields, $mappingExepFile;
    if (!$isMappingHeaderAdded) {
        $mappingExepFile = new SplFileObject($exceptionDir, 'w');
        $mappingExepFile->fputcsv(array_merge($itemMasterFields, $itemDistributorFields));
        $isMappingHeaderAdded = true;
    }
    $filterItemData = filterItemMasterFields($itemKeyValues);
    $filterDistData = filterItemDistributorFields($itemKeyValues);
    $exceptionKeyValues = array_merge($filterItemData, $filterDistData);
    $mappingExepFile->fputcsv($exceptionKeyValues);
}
Example #2
0
function mappingItemWithDistributor($itemId, $itemKeyValues)
{
    global $currentDistributorId, $itemDistTableFields;
    $filterDistData = filterItemDistributorFields($itemKeyValues);
    $itemDistValues = array_values($filterDistData);
    $filterItemData = filterItemMasterFields($itemKeyValues);
    $nameRuleQuery = "INSERT INTO itemname_rules (`itemId`, `Name`) VALUES(" . $itemId . ", '" . $filterItemData['name'] . "')";
    $nameRuleResult = mysql_query($nameRuleQuery, getMyConnection());
    if ($nameRuleResult) {
        $query = "INSERT INTO item_distributor (`ItemId`, `DistributorId`, `" . implode("`, `", $itemDistTableFields) . "`) " . "VALUES(" . $itemId . ", " . $currentDistributorId . ", '" . implode("', '", $itemDistValues) . "')" . " ON DUPLICATE KEY UPDATE ItemId=" . $itemId . ", DistributorId= " . $currentDistributorId . ", Mrp= " . $filterDistData['mrp'] . ", SellingPrice=" . $filterDistData['selling price'] . ", Offer='" . $filterDistData['offer'] . "'";
        $res = mysql_query($query, getMyConnection());
        return $res;
    }
    closeConnection();
}