Ejemplo n.º 1
0
    if (!$bSuccess) {
        echo CUtil::PhpToJSObject(array('ERROR' => 'PRODUCT_ROWS_SAVING_ERROR'));
    } else {
        echo CUtil::PhpToJSObject(array('SAVE_PRODUCT_ROWS' => 'OK'));
    }
} elseif ($mode === 'REMOVE_PRODUCT') {
    if ($perms->HavePerm($ownerName, BX_CRM_PERM_NONE, 'WRITE')) {
        echo CUtil::PhpToJSObject(array('ERROR' => 'PERMISSION_DENIED'));
        die;
    }
    $ID = isset($_POST['ID']) ? intval($_POST['ID']) : 0;
    if ($ID <= 0) {
        echo CUtil::PhpToJSObject(array('ERROR' => 'ID_NOT_FOUND'));
        die;
    }
    if (!CCrmProductRow::Delete($ID)) {
        echo CUtil::PhpToJSObject(array('ERROR' => CCrmProductRow::GetLastError()));
    } else {
        echo CUtil::PhpToJSObject(array('DELETED_PRODUCT_ID' => $ID));
    }
} elseif ($mode === 'CALCULATE_TOTALS') {
    if ($perms->HavePerm($ownerName, BX_CRM_PERM_NONE, 'WRITE')) {
        echo CUtil::PhpToJSObject(array('ERROR' => 'PERMISSION_DENIED'));
        die;
    }
    $productRows = isset($_POST['PRODUCTS']) && is_array($_POST['PRODUCTS']) ? $_POST['PRODUCTS'] : array();
    $totalDiscount = 0.0;
    foreach ($productRows as &$productRow) {
        $productRow['ID'] = isset($productRow['ID']) ? intval($productRow['ID']) : 0;
        $productRow['PRODUCT_ID'] = isset($productRow['PRODUCT_ID']) ? intval($productRow['PRODUCT_ID']) : 0;
        $productRow['PRODUCT_NAME'] = isset($productRow['PRODUCT_NAME']) ? $productRow['PRODUCT_NAME'] : '';
Ejemplo n.º 2
0
 protected function innerDelete($ID, &$errors)
 {
     $entity = CCrmProductRow::GetByID($ID);
     if (!is_array($entity)) {
         $errors[] = "Product Row not found";
         return false;
     }
     if (!CCrmAuthorizationHelper::CheckDeletePermission(CCrmProductRow::ResolveOwnerTypeName($entity['OWNER_TYPE']), $entity['OWNER_ID'])) {
         $errors[] = 'Access denied.';
         return false;
     }
     $result = CCrmProductRow::Delete($ID, true, true);
     if ($result !== true) {
         $errors[] = CCrmProductRow::GetLastError();
     }
     return $result;
 }