diff options
Diffstat (limited to 'admin/WebConsole')
-rw-r--r-- | admin/WebConsole/gestores/gestor_programaciones.php | 51 | ||||
-rw-r--r-- | admin/WebConsole/includes/restfunctions.php | 37 |
2 files changed, 58 insertions, 30 deletions
diff --git a/admin/WebConsole/gestores/gestor_programaciones.php b/admin/WebConsole/gestores/gestor_programaciones.php index 599427e5..4df4d2ce 100644 --- a/admin/WebConsole/gestores/gestor_programaciones.php +++ b/admin/WebConsole/gestores/gestor_programaciones.php @@ -12,6 +12,7 @@ include_once("../includes/ctrlacc.php"); include_once("../includes/CreaComando.php"); include_once("../clases/AdoPhp.php"); include_once("../includes/comunes.php"); +include_once("../includes/restfunctions.php"); //________________________________________________________________________________________________________ $op_alta=1; $op_modificacion=2; @@ -76,40 +77,30 @@ if($wsw_sus=='true') else $psw_sus=0 ; -$cmd=CreaComando($cadenaconexion); // Crea objeto comando -$resul=false; -if ($cmd){ - $resul=Gestiona(); - $cmd->Conexion->Cerrar(); -} if($pswop!=$op_suspension){ - if (!$resul){ // Ha ocurrido algún error - $reporerr=$cmd->UltimoError(); - $repordes=$cmd->DescripUltimoError(); - echo "error_programacion()"; - } - else{ // programacion registrada correctamente - switch($pswop){ - case $op_modificacion : - $idr=$pidprogramacion; // Identificador de la programacion modificada - $swop=$op_modificacion; - break; - case $op_alta: - $idr=$pidprogramacion; // Identificador de la programacion nueva - $swop=$op_alta; - break; - case $op_eliminacion : - $idr=$pidprogramacion; // Identificador de la programacion eliminada - $swop=$op_eliminacion; - break; - default: - break; - } - echo 'registro_programacion('.$idr.',"'.$pnombrebloque.'",'.$swop.')'; + $result; + $idr=$pidprogramacion; + switch($pswop){ + case $op_modificacion : + $swop=$op_modificacion; + break; + case $op_alta: + $result = create_schedule($pidentificador, + $pnombrebloque, $pannos, $pmeses, $pdiario, + $phoras, $pampm, $pminutos); + $swop=$op_alta; + break; + case $op_eliminacion : + $result = delete_schedule($pidprogramacion); + $swop=$op_eliminacion; + break; + default: + break; } + echo 'registro_programacion('.$idr.',"'.$pnombrebloque.'",'.$swop.')'; } else{ - if (!$resul){ // Ha ocurrido algún error + if ($resul) { // Ha ocurrido algún error $reporerr=0; $repordes="Error al suspender la programación"; echo 'error_programacion()'; diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index 4813c010..828a2bef 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -27,6 +27,8 @@ define('OG_REST_CMD_RESTORE_BASIC_IMAGE', 'image/restore/basic'); define('OG_REST_CMD_RESTORE_INCREMENTAL_IMAGE', 'image/restore/incremental'); define('OG_REST_CMD_RUN_SCHEDULE', 'run/schedule'); define('OG_REST_CMD_RUN_TASK', 'task/run'); +define('OG_REST_CMD_CREATE_SCHEDULE', 'schedule/create'); +define('OG_REST_CMD_DELETE_SCHEDULE', 'schedule/delete'); define('OG_REST_PARAM_CLIENTS', 'clients'); define('OG_REST_PARAM_ADDR', 'addr'); @@ -61,6 +63,13 @@ define('OG_REST_PARAM_DIFF_NAME', 'diff_name'); define('OG_REST_PARAM_METHOD', 'method'); define('OG_REST_PARAM_ECHO', 'echo'); define('OG_REST_PARAM_TASK', 'task'); +define('OG_REST_PARAM_TIME_PARAMS', 'time_params'); +define('OG_REST_PARAM_YEARS', 'years'); +define('OG_REST_PARAM_MONTHS', 'months'); +define('OG_REST_PARAM_DAYS', 'days'); +define('OG_REST_PARAM_HOURS', 'hours'); +define('OG_REST_PARAM_AM_PM', 'am_pm'); +define('OG_REST_PARAM_MINUTES', 'minutes'); $conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmServer.cfg'); define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['APITOKEN']); @@ -551,6 +560,34 @@ function run_task($task_id) { return common_request(OG_REST_CMD_RUN_TASK, POST, $data); } +function create_schedule($task_id, $name, $years, $months, $days, $hours, + $am_pm, $minutes) { + + $data = array ( + OG_REST_PARAM_TASK => $task_id, + OG_REST_PARAM_NAME => $name, + OG_REST_PARAM_TIME_PARAMS => array ( + OG_REST_PARAM_YEARS => intval($years), + OG_REST_PARAM_MONTHS => intval($months), + OG_REST_PARAM_DAYS => intval($days), + OG_REST_PARAM_HOURS => intval($hours), + OG_REST_PARAM_AM_PM => intval($am_pm), + OG_REST_PARAM_MINUTES => intval($minutes) + ) + ); + + return common_request(OG_REST_CMD_CREATE_SCHEDULE, POST, $data); +} + +function delete_schedule($schedule_id) { + + $data = array ( + OG_REST_PARAM_ID => $schedule_id, + ); + + return common_request(OG_REST_CMD_DELETE_SCHEDULE, POST, $data); +} + /* * @function multiRequest. * @param URLs array (may include header and POST data), cURL options array. |