Merge pull request #2504 from luisfernandosl/BUG-13546

BUG 13546 "Creacion de una nueva plantilla sin..." SOLVED
This commit is contained in:
julceslauhub
2014-07-17 16:00:27 -04:00
2 changed files with 55 additions and 17 deletions

View File

@@ -695,6 +695,21 @@ try {
//$json = new Services_JSON(); //$json = new Services_JSON();
$sOutput = Bootstrap::json_encode($response); $sOutput = Bootstrap::json_encode($response);
break; break;
case "verifyNameFile":
$response = array();
$status = "OK";
$filename = $_POST["filename"];
$pathDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST["pro_uid"] . PATH_SEP;
if (file_exists($pathDirectory . PATH_SEP . $filename)) {
$status = "ERROR";
}
$response["status"] = $status;
echo Bootstrap::json_encode($response);
break;
} }
if (isset($sOutput)) { if (isset($sOutput)) {
die($sOutput); die($sOutput);

View File

@@ -152,25 +152,48 @@ function showCreateEmptyOptions(e, MAIN_DIRECTORY){
} }
function saveEmptyFile(){ function saveEmptyFile(){
var fileName = getField('emptyfilename').value + ".html"; var fileName = getField("emptyfilename").value.trim();
fileName = fileName.trim();
var oRPC = new leimnud.module.rpc.xmlhttp({ if(fileName != "") {
url : 'processes_Ajax', fileName = fileName + ".html";
args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent=' fileName = fileName.trim();
});
oRPC.callback = function(rpc){ var rpcAjax = new leimnud.module.rpc.xmlhttp({
showCreateEmptyOptionsPanel.remove(); url: "processes_Ajax",
/// goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); method: "POST",
if(typeof(CURRENT_MAIN_DIRECTORY) != "undefined" ) { args: "action=verifyNameFile&filename=" + fileName + "&pro_uid=" + CURRENT_PRO_UID + "&MAIN_DIRECTORY=" + CURRENT_MAIN_DIRECTORY + "&fcontent="
goToDirectory(CURRENT_PRO_UID, CURRENT_MAIN_DIRECTORY, ''); });
} else {
goToDirectory(CURRENT_PRO_UID, 'mailTemplates', ''); rpcAjax.callback = function (rpc)
} {
editFile(CURRENT_PRO_UID, fileName) var response = rpc.xmlhttp.responseText.parseJSON();
}.extend(this); var status = response.status;
oRPC.make();
if (status == "OK") {
var oRPC = new leimnud.module.rpc.xmlhttp({
url : 'processes_Ajax',
args: 'action=saveFile&filename='+fileName+'&pro_uid='+CURRENT_PRO_UID+'&MAIN_DIRECTORY='+CURRENT_MAIN_DIRECTORY+'&fcontent='
});
oRPC.callback = function(rpc){
showCreateEmptyOptionsPanel.remove();
/// goToDirectory(CURRENT_PRO_UID, 'mailTemplates', '');
if(typeof(CURRENT_MAIN_DIRECTORY) != "undefined" ) {
goToDirectory(CURRENT_PRO_UID, CURRENT_MAIN_DIRECTORY, '');
} else {
goToDirectory(CURRENT_PRO_UID, 'mailTemplates', '');
}
editFile(CURRENT_PRO_UID, fileName)
}.extend(this);
oRPC.make();
} else {
new leimnud.module.app.alert().make({label: _("ID_EXISTS_FILES")});
}
}.extend(this);
rpcAjax.make();
} else {
new leimnud.module.app.alert().make({label: _("ID_FILENAME_REQUIRED")});
}
} }
function xReaload(){ function xReaload(){