var PcsysWmsBarcodeSynchronizer = function () {
    var self = {};
    self.tmp = null;

    self.SynchronizeWithWmsDatabase = function () {
        var requester = new AjaxRequest({
            data: {},
            url: "GetBarcodeDescriptorsJson",
            success: self.SynchronizationSuccessfull,
            error: self.ErrorSynchronizing
        });
        requester.ExecuteRequest();
    }

    self.ErrorSynchronizing = function (request, status, error) {
        /// <summary>Called by submit(location) on error</summary>
        $("#receive_purchaseorder_errortxt").text("Fejl: Indkøbsordren kunne ikke identificeres");
        //alert('Error');
    }

    self.SynchronizationSuccessfull = function (data, status, xhr) {
        self.tmp = data;
        $(data.d).each(function (index, barcode){
            barcodedescriptorlist.addDescriptor(barcode)
        });
        // example barcode to test the barcodedescriptorlist
        // C10159123123321321101234562120130605001
//        barcodedescriptorlist.setDescriptor("]C10159123123321321101234562120130605001");

//        printProps(barcodedescriptorlist.valueDescriptors,'barcodedescriptorlist.valueDescriptors');
//        for (var i = 0; i < barcodedescriptorlist.valueDescriptors.length; i++){
//            printProps(barcodedescriptorlist.valueDescriptors[i],"bdvd");
//        }
    }
    return self;
}

var barcodeSynchronizer = PcsysWmsBarcodeSynchronizer();