Documente Academic
Documente Profesional
Documente Cultură
jsp:
<%-- <!-- DE AQUI TENGO QUE COMENTAR-->
=======
<!------------------------inventoryInputId---------------------------------------------------------->
>>>>>>> .r305
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="text" class="form-control" tooltippopup-delay="1000"
tooltip="Id de la Entrada de Inventario"
placeholder="Id de la Entrada de Inventario"
ng-model="inventoryInputId" ngchange="inventoryInputIdEmpty()" maxlength="11"
pattern = "[0-9]+"
oninvalid="setCustomValidity('Ingrese un
valor numrico entero')"
oninput="setCustomValidity('')">
class="glyphicon glyphiconsearch"></span></a>
</div>
<!-- remove -->
<div class = "col-md-1">
<a ng-show="editing" ng-click="remove()" href="#"
class="btn btn-danger">
<span class="glyphicon glyphicontrash"></span>
</a>
</div>
</div>
<!------------------------inventoryMasterId---------------------------------------------------------->
<div class="row">
<div class="col-md-4">
<label for="inventoryMasterId" >Id del Maestro de
Inventario</label>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<input type="text" class="form-control" tooltippopup-delay="1000"
tooltip="Id del Maestro de Inventario"
placeholder="Id del Maestro de Inventario"
ng-model="inventoryMasterId" ngchange="" pattern = "[0-9]+"
<br>
<div class="row">
<div class="col-md-4">
<h5> Cantidad </h5>
<div class="form-group">
<input type="text" class="form-control" ngmodel="amount"
placeholder="Cantidad" tooltip-popupdelay="1000"
<!-- -----------------------date----------------------------------------------------------------------->
<br>
<div class="row">
<div class="col-md-4">
<div class="input-group">
<!-- -----------------------time----------------------------------------------------------------------->
</div>
</div>
</div> --%>
.js
// calendar settings.
$scope.dateMax = new Date();
$scope.setDate = function()
{
console.log("Selected date: "+ $scope.date);
$scope.date = $scope.date;
}
$scope.dateOptions = {
formatYear : 'yy',
startingDay : 1
};
//time settings.
//settings
$scope.time = new Date();
$scope.hstep = 1;
$scope.mstep = 10;
$scope.ismeridian = true;
//reset
var d = new Date();
$scope.time = d;
//end time Settings
/*
//Function to clear the window form
$scope.clearForm = function()
{
$scope.inventoryInputId= "";
$scope.inventoryMasterId= "";
$scope.useId = "";
$scope.amount= "";
$scope.unitCost= "";
$scope.editing = false;
$scope.searched = false;
}
//$scope.isUseIdInputEmpty = true;
}
else if($scope.inventoryInputId !="" ||
$scope.inventoryInputId != null)
{
console.log("Id inventoryM tiene algo");
$scope.isInventoryInputIdInputEmpty=false;
}
}
$http.get(url).success(function(data)
{
$rootScope.inventoryInput = data;
if($scope.isInventoryInputIdInputEmpty == true)
{
var modalData = {};
modalData.list =
$rootScope.inventoryInput;
modalData.keyName = 'id';
modalData.selectWhat = 'la
Entrada de Inventario';
modalData.femOrMale = 'fem';
var modalInstance =
$modal.open({
templateUrl :
'http://localhost:8080/argusinventory/protected/admin/dialogs/itemSelectorDialog.jsp',
controller :
'modalController1',
resolve : {
data : function() {
return
modalData;
}
}
});
modalInstance.result.then(function(selectedItem1)
{
if(selectedItem1 == null)
return;
$scope.editing = true;
$scope.searched = true;
$scope.inventoryInputId =
selectedItem1.id;
$scope.inventoryMasterId =
selectedItem1.inventoryMasterId.id;
$scope.amount =
selectedItem1.amount;
$scope.unitCost =
selectedItem1.unitCost;
$scope.date =
selectedItem1.date;
//set Time
var colonPos =
selectedItem1.time.search(":");
var hours =
selectedItem1.time.substring(0, colonPos);
var auxStr =
selectedItem1.time.substring(colonPos + 1);
colonPos =
auxStr.search(":");
var minutes =
auxStr.substring(0, colonPos);
d.setMinutes(parseInt(minutes));
$scope.time = d;
console.log(selectedItem1);
}, function() {
$log.info('Modal dismissed
at: ' + new Date());
});
}
else
{
url= "http://localhost:8080/argusinventory/protected/guests/inventoryInput/findOne"
var config = {
params :
{
inventoryInputData :
inventoryInputString
}
};
$scope.editing =
true;
$scope.searched =
true;
$scope.inventoryInputId = selectedItem.id;
$scope.inventoryMasterId = selectedItem.inventoryMaster.id;
$scope.amount =
selectedItem.amount;
$scope.unitCost =
selectedItem.unitCost;
selectedItem.date;
$scope.date=
//With the names as they appear in the model
$scope.time =
selectedItem.time;
}
});
}).error(function() {
};
$http.get(url).success(function(data)
{
$rootScope.inventoryMaster = data;
if($scope.isInventoryMasterIdInputEmpty == true)
{
var modalData = {};
modalData.list =
$rootScope.inventoryMaster;
modalData.firstKey = 'id';
modalData.secondKey =
'description';
modalData.selectWhat = 'el
Maestro de Inventario';
modalData.femOrMale = 'male';
var modalInstance =
$modal.open({
templateUrl :
'http://localhost:8080/argusinventory/protected/admin/dialogs/itemSelectorDialogTwoKeys.jsp',
controller :
'modalController',
resolve : {
data : function() {
return
modalData;
}
}
});
modalInstance.result.then(function(selectedItem)
{
if(selectedItem == null)
return;
$scope.inventoryMasterId =
selectedItem.id;
console.log(selectedItem);
}, function() {
$log.info('Modal dismissed
at: ' + new Date());
});
}
}).error(function() {
};
/*
$scope.remove= function()
{
if($scope.editing == false )
return;
var config = {
params : {
inventoryInputData : inventoryInputString
}
};
$http.post(url, null,config)
.success(function(data, status, headers, config)
{
if (data.error_code == 997)
sweetAlert("Oops...",
"Esta Entrada de Inventario no esta
registrada",
"error");
else
{
swal({ title: "Operacion Exitosa!",
text: "Entrada de Inventario
eliminada",
type: "success",
showCancelButton: false,
confirmButtonText: "Ok",
closeOnConfirm: false
}, function(){
location.reload();
});
}
}).error(function(data, status, headers, config)
{
sweetAlert("Oops...",
inventoryInputString.inventoryInputId =
parseInt($scope.inventoryInputId);
inventoryInputString.inventoryMasterId =
parseInt($scope.inventoryMasterId);
inventoryInputString.amount =
parseFloat($scope.amount);
inventoryInputString.unitCost =
parseFloat($scope.unitCost);
//get date
inventoryInputString.date = $scope.date;
console.log($scope.date);
//get time
inventoryInputString.time = $scope.time.getHours() +
":" +
$scope.time.getMinutes();
var config = {
params : {
inventoryInputData : inventoryInputString
}
};
if ($scope.editing)
url = 'http://localhost:8080/argusinventory/protected/guests/inventoryInput/update';
"error");
else if(data.error_code == 998)
sweetAlert("Oops...",
"Verifique que el Maestro de
Inventario y el Usuario Existan",
"error");
else if(data.error_code == 977)
sweetAlert("Oops...",
"Error Creando los Record de
Entradas Asociados a su Entrada de Inventario",
"error");
else
{
swal({title: "Operacion Exitosa!",
text: "Entrada de Inventario " +
($scope.editing ? "editada!" : "creada!"),
type: "success"},
function()
{
location.reload()
}
);
}
}).error(function(data, status, headers, config)
{
sweetAlert("Oops...",
"Error creando la Entrada de Inventario",
"error");
});
console.log("Array" +
JSON.stringify(inventoryInputString));
}
})
*/
});
})(window.angular);
$scope.list = data.list;
$scope.firstKey = data.firstKey;
$scope.secondKey = data.secondKey;
$scope.selectWhat = data.selectWhat;
$scope.femOrMale = data.femOrMale == 'fem' ? 'a': 'o'; //this is for
$scope.selectedIndex = 0;
$scope.ok = function()
{
$modalInstance.close($scope.selectedItem);
};
$scope.cancel = function()
{
$modalInstance.dismiss('cancel');
};
});
})(window.angular);
/*
//MODAL DIALOG TO SHOW A INVENTORYMASTER LIST AND SELECT ONE
(function(angular) {
'use strict';
$scope.list = data.list;
$scope.keyName = data.keyName;
$scope.selectWhat = data.selectWhat;
$scope.femOrMale = data.femOrMale == 'fem' ? 'a': 'o'; //this is for
the label: selectWhat seleccionad@: ...
$scope.selectedIndex = 0;
$scope.ok = function()
{
$modalInstance.close($scope.selectedItem1);
};
$scope.cancel = function()
{
$modalInstance.dismiss('cancel');
};
});
})(window.angular); */
--------------Controller-------------@SuppressWarnings("unchecked")
@RequestMapping(value = "/protected/guests/inventoryInput/create", method
= RequestMethod.POST)
public @ResponseBody JSONObject
createInventoryInput(@RequestParam(required = true) String inventoryInputData,
final HttpServletResponse response) throws
JsonProcessingException,
IOException
{
getInventoryMasterById(actualObj.findValue("inventoryMasterId").getIntValue());
int userauxid= 1; //userid just to test the table, we'd need set a user
strategy later
User user = userService.getUserByID(userauxid);
return result;
inventoryInput.setInventoryMasterId(inventoryMaster);
inventoryInput.setUserId(user);
inventoryInput.setAmount((float)
(actualObj.findValue("amount").getDoubleValue()));
inventoryInput.setUnitCost((float)
(actualObj.findValue("unitCost").getDoubleValue()));
//setDate
Date dateD = Date.valueOf(date);
inventoryInput.setDate(dateD);
//setTime
inventoryInput.setTime(actualObj.findValue("time").getTextValue());
InventoryInput inventoryInputSaved =
inventoryInputService.create(inventoryInput);
if(inventoryInputSaved == null)
{
result.put("status", "error");
result.put("error_code", "999");
return result;
}
for(int i=0;i<inputRecordAmount;i++)
{
InputRecord inputRecord = new InputRecord();
inputRecord.setInventoryInputId(inventoryInputSaved);
InputRecord inputRecordCreated =
inputRecordService.create(inputRecord);
if(inputRecordCreated == null)
{
result.put("status", "error");
result.put("error_code", "977");
return result;
}
}
result.put("status", "success");
return result;
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/protected/guests/inventoryInput/remove",
method = RequestMethod.POST)
public @ResponseBody JSONObject
removeInventoryInput(@RequestParam(required = true) String inventoryInputData,
final HttpServletResponse response) throws
JsonProcessingException,
IOException
{
JSONObject result = new JSONObject();
ObjectMapper mapper = new ObjectMapper();
inventoryInput.setId((actualObj.findValue("id").getIntValue()));
System.err.println("Estoy en el controlador luego de validar");
InventoryInput inventoryInputremoved =
inventoryInputService.remove(inventoryInput);
if(inventoryInputremoved == null)
{
result.put("status", "error");
result.put("error_code", "998");
return result;
}
result.put("status", "success");
return result;
}