예제 #1
0
파일: DB.php 프로젝트: sandeepsis/nuwax
    if (trim($_REQUEST['voucherdate']) == "") {
        $_SESSION['msg'] = 'Please select Voucher date';
        $num = 'danger';
        $url = ADMIN_URL . "/purchaseorders/add.php";
        $general->redirectUrl($url, $num);
        exit;
    }
    $fieldvalues = array('voucherno' => $_REQUEST['voucherno'], 'productid' => $_REQUEST['product'], 'productquantity' => $_REQUEST['productqty'], "name" => $_REQUEST['name'], "emailaddress" => $_REQUEST['emailaddress'], "contactno" => $_REQUEST['contactno'], "voucherdate" => $_REQUEST['voucherdate'], 'vouchertype' => $_REQUEST['vouchertype'], "remark" => $_REQUEST['remark'], "date_added" => date('Y-m-d H:i:s'));
    $updated = $Purchaseorder->addPurchaseorder($fieldvalues);
    if ($updated) {
        $rows = $Purchaseorder->getProductById($_REQUEST['product']);
        $curr_stock = $rows->current_stock;
        $new_stock = $curr_stock + $_REQUEST['productqty'];
        $fieldvalues1 = array('current_stock' => $new_stock);
        $cond = array('id' => $_REQUEST['product']);
        $Purchaseorder->updateProduct($fieldvalues1, $cond);
    }
    if ($updated) {
        $general->addLogAction($_SESSION['adm_user_id'], 'Added', $updated, 'Purchase orders', $_SESSION['adm_status']);
        $error = 'success';
        $_SESSION['msg'] = 'Record added successfully.';
    } else {
        $error = 'danger';
        $_SESSION['msg'] = 'Error adding record.';
    }
    $url = ADMIN_URL . "/purchaseorders/index.php";
    $general->redirectUrl($url, $error);
    exit;
}
/*********************************************************************************************************/
if ($_REQUEST['FLAG'] == 'EDIT_PURCHASE') {