예제 #1
0
function getProductAvailableQty($materialId)
{
    $getReturnMessage = new CommonMethods();
    global $dbh;
    $stmt = $dbh->prepare("SELECT * FROM inventory WHERE materialid={$materialId}");
    if ($stmt->execute()) {
        $json_array = array();
        while ($result2 = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $inventoryData = array();
            $inventoryData['warehouseid'] = $result2['warehouseid'];
            $inventoryData['companyid'] = $result2['companyid'];
            $inventoryData['inventoryid'] = $result2['inventoryid'];
            $inventoryData['totalquantity'] = $result2['totalquantity'];
            $inventoryData['packagingtype'] = $result2['packagingtype'];
            $inventoryData['packagingsize'] = $result2['packagingsize'];
            $warehouseId = $result2['warehouseid'];
            $companyId = $result2['companyid'];
            $inventoryData['companyName'] = DatabaseCommonOperations::getCompanyName($warehouseId);
            $inventoryData['warehouseName'] = DatabaseCommonOperations::getWarehouseName($companyId);
            array_push($json_array, $inventoryData);
        }
        $json = json_encode($json_array);
        echo $json;
        //            $getReturnMessage->showAlert('success',$json );
    } else {
        $getReturnMessage->showAlert('error', "No Data Found");
    }
}
예제 #2
0
$productModel->_setProductAbbrevations($productDetails->abbrevation);
$productModel->_setProductUnitOfMeasure($productDetails->unitofmeasure);
$productModel->_setProductAlertQty($productDetails->alertquantity);
$productModel->_setProductColor($productDetails->color);
$productModel->_setProductDescription($productDetails->description);
$productModel->_setProductPackaging($productDetails->packaging);
$productModel->_setProductType($productDetails->materialtypeid);
$productModel->_setProductOperation($productDetails->opertaion);
$productObj = new Product($productModel);
switch ($productDetails->opertaion) {
    case 'insert':
        # code...
        if (!$productObj->isAvailable($dbh)) {
            $productObj->insertProductInToDb($dbh, $userId);
        } else {
            $showAlerts->showAlert("Failure", "Product you are trying to add is already added");
        }
        break;
    case 'delete':
        # code...
        //$productObj = new Product();
        $productObj->deleteProduct($dbh, $userId, $productDetails);
        break;
    case 'modify':
        if ($productDetails->isProductMasterTable || $productDetails->isProductDetailsTable || $productDetails->isProductPackagingTable || $productDetails->isProductMaterialTable) {
            $productObj->updateProduct($dbh, $userId, $productDetails);
        } else {
            $showAlerts->showAlert('Failure', "Nothing to update");
        }
        break;
    default: