Primer commit del sistema avantika sin cambios
This commit is contained in:
108
ajax/motivos.php
Executable file
108
ajax/motivos.php
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
include_once('../init.php');
|
||||
include_once('../config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
switch($_POST["type"]){
|
||||
|
||||
case 'addMotivo':
|
||||
|
||||
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/agregar-motivo-popup.tpl');
|
||||
|
||||
break;
|
||||
|
||||
case 'saveMotivo':
|
||||
|
||||
$motivo->setNombre($_POST['name']);
|
||||
|
||||
if(!$motivo->Save())
|
||||
{
|
||||
echo 'fail[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
||||
}else
|
||||
{
|
||||
echo 'ok[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
||||
echo '[#]';
|
||||
|
||||
$motivos = $motivo->Enumerate();
|
||||
$motivos["items"] = $util->EncodeResult($motivos["items"]);
|
||||
|
||||
$smarty->assign('motivos', $motivos);
|
||||
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
||||
$smarty->display(DOC_ROOT.'/templates/lists/motivos.tpl');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'editMotivo':
|
||||
|
||||
$motivoId = $_POST['motivoId'];
|
||||
|
||||
$motivo->setMotivoId($motivoId);
|
||||
$info = $motivo->Info();
|
||||
|
||||
$info['nombre'] = utf8_encode($info['nombre']);
|
||||
|
||||
$smarty->assign('info', $info);
|
||||
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/editar-motivo-popup.tpl');
|
||||
|
||||
break;
|
||||
|
||||
case 'saveEditMotivo':
|
||||
|
||||
$motivo->setMotivoId($_POST['motivoId']);
|
||||
$motivo->setNombre($_POST['name']);
|
||||
|
||||
if(!$motivo->Update())
|
||||
{
|
||||
echo 'fail[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
||||
}else
|
||||
{
|
||||
echo 'ok[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
||||
echo '[#]';
|
||||
|
||||
$motivos = $motivo->Enumerate();
|
||||
$motivos["items"] = $util->EncodeResult($motivos["items"]);
|
||||
|
||||
$smarty->assign('motivos', $motivos);
|
||||
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
||||
$smarty->display(DOC_ROOT.'/templates/lists/motivos.tpl');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'deleteMotivo':
|
||||
|
||||
$motivoId = $_POST['motivoId'];
|
||||
|
||||
$motivo->setMotivoId($motivoId);
|
||||
|
||||
if(!$motivo->Baja())
|
||||
{
|
||||
echo 'fail[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status_on_popup.tpl');
|
||||
}else
|
||||
{
|
||||
echo 'ok[#]';
|
||||
$smarty->display(DOC_ROOT.'/templates/boxes/status.tpl');
|
||||
echo '[#]';
|
||||
|
||||
$motivos = $motivo->Enumerate();
|
||||
$motivos["items"] = $util->EncodeResult($motivos["items"]);
|
||||
|
||||
$smarty->assign('motivos', $motivos);
|
||||
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
||||
$smarty->display(DOC_ROOT.'/templates/lists/motivos.tpl');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}//switch
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user