<?php
/**
 * Planeación de impresión — vista semanal por máquina.
 *
 * @package Logistica
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

require_once LOGISTICA_PLUGIN_DIR . 'admin/views/partials.php';

$week_start = Logistica_Print_Planning::week_start();
$machines   = Logistica_Print_Planning::get_machines();
$days       = Logistica_Print_Planning::week_days( $week_start );
$statuses   = Logistica_Print_Planning::get_statuses();
$complexities = Logistica_Print_Planning::get_complexity_labels();
$labor_types  = Logistica_Print_Planning::get_labor_types();
$papel_materials = Logistica_Print_Planning::get_papel_materials();
$field_options   = Logistica_Print_Planning::get_field_options();
$day_hours    = Logistica_Print_Planning::default_day_hours();
$day_types    = Logistica_Print_Planning::day_types();
$panel_year            = (int) wp_date( 'Y' );
$show_planeacion_board = ! is_admin();
$frontend_panel_url    = logistica_tab_url( 'logistica-planeacion-impresion', 'frontend' );

logistica_admin_header( __( 'Planeación impresión', 'logistica' ) );
?>
<section class="logistica-panel logistica-planeacion<?php echo $show_planeacion_board ? '' : ' logistica-planeacion--admin-settings'; ?>" data-planeacion-board<?php echo $show_planeacion_board ? '' : ' data-planeacion-admin-settings-only="1"'; ?>>
	<?php if ( ! logistica_is_tabbed_shell() ) : ?>
		<?php logistica_tab_loading_overlay( logistica_tab_loading_message( 'logistica-planeacion-impresion' ) ); ?>
	<?php endif; ?>
	<div class="logistica-page-toolbar logistica-planeacion__toolbar">
		<?php
		if ( $show_planeacion_board ) {
			logistica_page_toolbar_intro(
				__( 'Planeación de impresión', 'logistica' ),
				__( 'Organiza trabajos por máquina y día. Configura la jornada en cada columna; la duración se calcula con 1000 tamaños = 60 min.', 'logistica' ),
				'dashicons-calendar-alt'
			);
		} else {
			logistica_page_toolbar_intro(
				__( 'Configuración planeación impresión', 'logistica' ),
				__( 'Opciones de administración para listas desplegables. La planeación operativa (Gantt, actividades e importación) está en el panel público.', 'logistica' ),
				'dashicons-admin-settings'
			);
		}
		?>
		<div class="logistica-planeacion__toolbar-actions">
			<span class="logistica-planeacion__save-status" data-planeacion-save-status aria-live="polite"></span>
		</div>
	</div>

	<?php if ( ! $show_planeacion_board ) : ?>
	<div class="logistica-planeacion__admin-settings">
		<?php if ( $frontend_panel_url ) : ?>
			<p class="logistica-planeacion__admin-settings-link">
				<a class="button button-secondary" href="<?php echo esc_url( $frontend_panel_url ); ?>"><?php esc_html_e( 'Abrir planeación en el panel público', 'logistica' ); ?></a>
			</p>
		<?php endif; ?>
		<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--secondary" data-action="planeacion-edit-field-options">
			<span class="dashicons dashicons-list-view" aria-hidden="true"></span>
			<?php esc_html_e( 'Listas desplegables', 'logistica' ); ?>
		</button>
	</div>
	<?php endif; ?>

	<?php if ( $show_planeacion_board ) : ?>
	<nav class="logistica-planeacion__machines" aria-label="<?php esc_attr_e( 'Máquinas', 'logistica' ); ?>" data-planeacion-machines></nav>

	<?php require LOGISTICA_PLUGIN_DIR . 'admin/views/partials/planeacion-config-toolbar.php'; ?>

	<?php require LOGISTICA_PLUGIN_DIR . 'admin/views/partials/planeacion-metrics.php'; ?>

	<ul class="logistica-planeacion__legend" aria-label="<?php esc_attr_e( 'Estados', 'logistica' ); ?>">
		<?php foreach ( $statuses as $key => $label ) : ?>
			<li>
				<span class="logistica-planeacion__status-swatch logistica-planeacion__status-swatch--<?php echo esc_attr( $key ); ?>"></span>
				<?php echo esc_html( $label ); ?>
			</li>
		<?php endforeach; ?>
	</ul>

	<div class="logistica-planeacion__board-section" data-excel-zoom-root="planeacion-impresion">
		<div class="logistica-planeacion__board-toolbar">
			<div class="logistica-planeacion__week-nav" aria-label="<?php esc_attr_e( 'Navegación semanal', 'logistica' ); ?>">
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--icon" data-action="planeacion-prev-week" aria-label="<?php esc_attr_e( 'Semana anterior', 'logistica' ); ?>">
					<span class="dashicons dashicons-arrow-left-alt2" aria-hidden="true"></span>
				</button>
				<span class="logistica-planeacion__week-label" data-planeacion-week-label></span>
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--icon" data-action="planeacion-next-week" aria-label="<?php esc_attr_e( 'Semana siguiente', 'logistica' ); ?>">
					<span class="dashicons dashicons-arrow-right-alt2" aria-hidden="true"></span>
				</button>
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--secondary logistica-planeacion__btn--compact" data-action="planeacion-today-week"><?php esc_html_e( 'Esta semana', 'logistica' ); ?></button>
			</div>
			<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--secondary logistica-planeacion__btn--compact logistica-planeacion-pedidos-open" data-action="planeacion-pedidos-open" data-planeacion-pedidos-module="impresion">
				<span class="dashicons dashicons-cart" aria-hidden="true"></span>
				<?php esc_html_e( 'Desde pedidos', 'logistica' ); ?>
			</button>
			<?php logistica_excel_table_zoom_controls(); ?>
		</div>
		<div class="logistica-planeacion__board-scroll" data-planeacion-scroll>
	<div class="logistica-planeacion__board" data-planeacion-grid>
		<?php foreach ( $days as $day ) : ?>
			<div class="logistica-planeacion__day" data-planeacion-day="<?php echo esc_attr( (string) $day['index'] ); ?>">
				<header class="logistica-planeacion__day-header">
					<div class="logistica-planeacion__day-title">
						<strong><?php echo esc_html( $day['label'] ); ?></strong>
						<span><?php echo esc_html( $day['short'] ); ?></span>
					</div>
					<label class="logistica-planeacion__day-type">
						<span class="screen-reader-text"><?php esc_html_e( 'Tipo de día', 'logistica' ); ?></span>
						<select
							data-planeacion-day-type="<?php echo esc_attr( (string) $day['index'] ); ?>"
							aria-label="<?php echo esc_attr( sprintf( __( 'Tipo de día %s', 'logistica' ), $day['label'] ) ); ?>"
						>
							<?php foreach ( $day_types as $type_key => $type_label ) : ?>
								<option value="<?php echo esc_attr( $type_key ); ?>"><?php echo esc_html( $type_label ); ?></option>
							<?php endforeach; ?>
						</select>
					</label>
					<div class="logistica-planeacion__day-hours">
						<label class="logistica-planeacion__time-field">
							<span class="screen-reader-text"><?php esc_html_e( 'Inicio jornada', 'logistica' ); ?></span>
							<input
								type="time"
								class="logistica-planeacion__time-input"
								value="<?php echo esc_attr( Logistica_Print_Planning::minutes_to_time_input( $day_hours[ (string) $day['index'] ]['start'] ?? 420 ) ); ?>"
								data-planeacion-day-start="<?php echo esc_attr( (string) $day['index'] ); ?>"
								aria-label="<?php echo esc_attr( sprintf( __( 'Inicio jornada %s', 'logistica' ), $day['label'] ) ); ?>"
							>
						</label>
						<span class="logistica-planeacion__day-hours-sep" aria-hidden="true">–</span>
						<label class="logistica-planeacion__time-field">
							<span class="screen-reader-text"><?php esc_html_e( 'Fin jornada', 'logistica' ); ?></span>
							<input
								type="time"
								class="logistica-planeacion__time-input"
								value="<?php echo esc_attr( Logistica_Print_Planning::minutes_to_time_input( $day_hours[ (string) $day['index'] ]['end'] ?? 1020 ) ); ?>"
								data-planeacion-day-end="<?php echo esc_attr( (string) $day['index'] ); ?>"
								aria-label="<?php echo esc_attr( sprintf( __( 'Fin jornada %s', 'logistica' ), $day['label'] ) ); ?>"
							>
						</label>
					</div>
					<button type="button" class="logistica-planeacion__day-add" data-action="planeacion-add-task-day" data-day="<?php echo esc_attr( (string) $day['index'] ); ?>" title="<?php esc_attr_e( 'Agregar actividad', 'logistica' ); ?>">+</button>
				</header>
				<div class="logistica-planeacion__day-body" data-planeacion-dropzone="<?php echo esc_attr( (string) $day['index'] ); ?>">
					<div class="logistica-planeacion__day-off" data-planeacion-day-off hidden>
						<span class="logistica-planeacion__day-off-icon dashicons dashicons-star-filled" aria-hidden="true"></span>
						<div class="logistica-planeacion__day-off-body">
							<strong data-planeacion-day-off-label><?php esc_html_e( 'Festivo', 'logistica' ); ?></strong>
							<p data-planeacion-day-off-desc><?php esc_html_e( 'Día no laborable. Sin actividades programadas.', 'logistica' ); ?></p>
						</div>
					</div>
					<div class="logistica-planeacion__timeline-scroll" data-planeacion-timeline-scroll hidden>
						<div class="logistica-planeacion__timeline" data-planeacion-timeline>
							<div class="logistica-planeacion__timeline-ruler" data-planeacion-timeline-ruler aria-hidden="true"></div>
							<div class="logistica-planeacion__timeline-track" data-planeacion-timeline-track></div>
						</div>
					</div>
					<p class="logistica-planeacion__empty" data-planeacion-empty hidden><?php esc_html_e( 'Sin actividades. Arrastra aquí o usa +.', 'logistica' ); ?></p>
				</div>
			</div>
		<?php endforeach; ?>
		<div class="logistica-planeacion__overflow-weeks" data-planeacion-overflow-weeks hidden></div>
	</div>
		</div>
	</div>
	<?php
	$planeacion_pedidos_module = 'impresion';
	$planeacion_pedidos_days   = $days;
	require LOGISTICA_PLUGIN_DIR . 'admin/views/partials/planeacion-pedidos-picker.php';
	unset( $planeacion_pedidos_module, $planeacion_pedidos_days );
	?>
	<?php endif; ?>
</section>

<?php if ( $show_planeacion_board ) : ?>
<dialog class="logistica-planeacion__modal" data-planeacion-modal>
	<form method="dialog" class="logistica-planeacion__modal-form" data-planeacion-form>
		<header class="logistica-planeacion__modal-header">
			<h3 data-planeacion-modal-title><?php esc_html_e( 'Actividad', 'logistica' ); ?></h3>
			<button type="button" class="logistica-planeacion__modal-close" data-action="planeacion-close-modal" aria-label="<?php esc_attr_e( 'Cerrar', 'logistica' ); ?>">&times;</button>
		</header>
		<div class="logistica-planeacion__modal-body">
			<input type="hidden" data-planeacion-field="id">
			<div class="logistica-planeacion__form-grid">
				<label>
					<span><?php esc_html_e( 'OP', 'logistica' ); ?></span>
					<input type="text" data-planeacion-field="op" placeholder="<?php esc_attr_e( 'Ej. 8510 o SIN OP', 'logistica' ); ?>">
				</label>
				<label>
					<span><?php esc_html_e( 'Día', 'logistica' ); ?></span>
					<select data-planeacion-field="day">
						<?php foreach ( $days as $day ) : ?>
							<option value="<?php echo esc_attr( (string) $day['index'] ); ?>"><?php echo esc_html( $day['label'] ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<label>
					<span><?php esc_html_e( 'Estado', 'logistica' ); ?></span>
					<select data-planeacion-field="status">
						<?php foreach ( $statuses as $key => $label ) : ?>
							<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<label class="logistica-planeacion__form-span-2">
					<span><?php esc_html_e( 'Tipo de labor', 'logistica' ); ?></span>
					<select data-planeacion-field="labor_type" data-planeacion-labor-type>
						<?php foreach ( $labor_types as $key => $label ) : ?>
							<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option>
						<?php endforeach; ?>
					</select>
					<small class="logistica-planeacion__field-hint logistica-planeacion__labor-hint" data-planeacion-labor-hint hidden></small>
				</label>
				<label class="logistica-planeacion__form-span-2">
					<span><?php esc_html_e( 'Descripción', 'logistica' ); ?></span>
					<input type="text" data-planeacion-field="labor" placeholder="<?php esc_attr_e( 'Ej. Lavado de máquina', 'logistica' ); ?>">
				</label>
				<div class="logistica-planeacion__form-span-2 logistica-planeacion__labor-section" data-planeacion-labor-section="tiraje">
				<label>
					<span><?php esc_html_e( 'Tamaños (tiraje)', 'logistica' ); ?></span>
					<input type="text" data-planeacion-field="tamanos" placeholder="<?php esc_attr_e( 'Ej. 2000 o 867 TIR', 'logistica' ); ?>">
					<small class="logistica-planeacion__field-hint"><?php esc_html_e( '1000 tamaños ≈ 60 min de impresión', 'logistica' ); ?></small>
				</label>
				<label>
					<span><?php esc_html_e( 'Complejidad', 'logistica' ); ?></span>
					<select data-planeacion-field="complexity">
						<?php foreach ( $complexities as $key => $label ) : ?>
							<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				</div>
				<label>
					<span><?php esc_html_e( 'Duración (min)', 'logistica' ); ?></span>
					<input type="number" min="15" step="15" data-planeacion-field="duration_minutes" data-planeacion-duration-input>
					<small class="logistica-planeacion__field-hint" data-planeacion-duration-hint hidden></small>
				</label>
				<?php require LOGISTICA_PLUGIN_DIR . 'admin/views/partials/planeacion-tintas-fields.php'; ?>
				<div class="logistica-planeacion__form-span-2 logistica-planeacion__labor-section logistica-planeacion__papel-fields" data-planeacion-labor-section="papel">
					<span class="logistica-planeacion__papel-title"><?php esc_html_e( 'Papel', 'logistica' ); ?></span>
					<div class="logistica-planeacion__papel-grid">
						<label>
							<span><?php esc_html_e( 'Ancho (cm)', 'logistica' ); ?></span>
							<input type="text" inputmode="decimal" data-planeacion-field="papel_ancho" placeholder="<?php esc_attr_e( 'Ej. 68', 'logistica' ); ?>">
						</label>
						<label>
							<span><?php esc_html_e( 'Largo (cm)', 'logistica' ); ?></span>
							<input type="text" inputmode="decimal" data-planeacion-field="papel_largo" placeholder="<?php esc_attr_e( 'Ej. 51', 'logistica' ); ?>">
						</label>
						<label>
							<span><?php esc_html_e( 'Gramaje', 'logistica' ); ?></span>
							<input type="text" inputmode="decimal" data-planeacion-field="papel_gramaje" placeholder="<?php esc_attr_e( 'Ej. 300', 'logistica' ); ?>">
						</label>
						<label>
							<span><?php esc_html_e( 'Material', 'logistica' ); ?></span>
							<select data-planeacion-field="papel_material" data-planeacion-options-list="papel_materials" data-planeacion-papel-material>
								<option value=""><?php esc_html_e( '—', 'logistica' ); ?></option>
							</select>
						</label>
						<label class="logistica-planeacion__papel-material-otro" data-planeacion-papel-material-otro hidden>
							<span><?php esc_html_e( 'Nombre del otro material', 'logistica' ); ?></span>
							<input type="text" data-planeacion-field="papel_material_otro" placeholder="<?php esc_attr_e( 'Ej. Couché mate', 'logistica' ); ?>">
						</label>
					</div>
				</div>
				<?php
				$check_fields = array(
					'montaje'    => __( 'Montaje', 'logistica' ),
					'prep_tinta' => __( 'Preparación de tintas', 'logistica' ),
					'planchas'   => __( 'Planchas', 'logistica' ),
					'meta'       => __( 'Cumplimiento de metas', 'logistica' ),
				);
				foreach ( $check_fields as $field_key => $field_label ) :
					?>
					<label data-planeacion-labor-field="<?php echo esc_attr( $field_key ); ?>">
						<span><?php echo esc_html( $field_label ); ?></span>
						<select data-planeacion-field="<?php echo esc_attr( $field_key ); ?>" data-planeacion-options-list="<?php echo esc_attr( $field_key ); ?>">
							<option value=""><?php esc_html_e( '—', 'logistica' ); ?></option>
						</select>
					</label>
				<?php endforeach; ?>
				<label>
					<span><?php esc_html_e( 'Inicio real', 'logistica' ); ?></span>
					<input type="time" class="logistica-planeacion__time-input" data-planeacion-field="actual_start">
				</label>
				<label>
					<span><?php esc_html_e( 'Fin real', 'logistica' ); ?></span>
					<input type="time" class="logistica-planeacion__time-input" data-planeacion-field="actual_end">
				</label>
				<label>
					<span><?php esc_html_e( 'Persona asignada', 'logistica' ); ?></span>
					<input type="text" data-planeacion-field="assigned_person" placeholder="<?php esc_attr_e( 'Operario responsable', 'logistica' ); ?>">
				</label>
				<label>
					<span><?php esc_html_e( 'Prioridad tablero', 'logistica' ); ?></span>
					<select data-planeacion-field="board_priority">
						<?php foreach ( Logistica_Production_Board::get_priorities() as $prio_key => $prio_label ) : ?>
							<option value="<?php echo esc_attr( $prio_key ); ?>"><?php echo esc_html( $prio_label ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<label class="logistica-planeacion__form-span-2">
					<span><?php esc_html_e( 'Novedad / alerta', 'logistica' ); ?></span>
					<select data-planeacion-field="board_alert">
						<?php foreach ( Logistica_Production_Board::get_alerts() as $alert_key => $alert_label ) : ?>
							<option value="<?php echo esc_attr( $alert_key ); ?>"><?php echo esc_html( $alert_label ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<label class="logistica-planeacion__form-span-2">
					<span><?php esc_html_e( 'Notas', 'logistica' ); ?></span>
					<textarea rows="2" data-planeacion-field="notes"></textarea>
				</label>
			</div>
		</div>
		<footer class="logistica-planeacion__modal-footer logistica-planeacion__modal-footer--task">
			<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--danger logistica-planeacion__btn--modal" data-action="planeacion-delete-task"><?php esc_html_e( 'Eliminar', 'logistica' ); ?></button>
			<div class="logistica-planeacion__modal-actions">
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--secondary logistica-planeacion__btn--modal" data-action="planeacion-close-modal"><?php esc_html_e( 'Cancelar', 'logistica' ); ?></button>
				<button type="submit" class="logistica-planeacion__btn logistica-planeacion__btn--primary logistica-planeacion__btn--modal"><?php esc_html_e( 'Guardar actividad', 'logistica' ); ?></button>
			</div>
		</footer>
	</form>
</dialog>

<dialog class="logistica-planeacion__modal logistica-planeacion__machine-modal" data-planeacion-machine-modal>
	<form class="logistica-planeacion__modal-form" data-planeacion-machine-form>
		<header class="logistica-planeacion__modal-header">
			<h3 data-planeacion-machine-modal-title><?php esc_html_e( 'Nueva máquina', 'logistica' ); ?></h3>
			<button type="button" class="logistica-planeacion__modal-close" data-action="planeacion-close-machine-modal" aria-label="<?php esc_attr_e( 'Cerrar', 'logistica' ); ?>">&times;</button>
		</header>
		<div class="logistica-planeacion__modal-body">
			<input type="hidden" data-planeacion-machine-slug value="">
			<p class="logistica-planeacion__field-hint" data-planeacion-machine-modal-hint><?php esc_html_e( 'Cada máquina tiene programación semanal independiente (tareas, horarios y jornadas propias).', 'logistica' ); ?></p>
			<label class="logistica-planeacion__form-span-2">
				<span><?php esc_html_e( 'Nombre de la máquina', 'logistica' ); ?></span>
				<input type="text" data-planeacion-machine-name placeholder="<?php esc_attr_e( 'Ej. Heidelberg XL', 'logistica' ); ?>" required>
			</label>
		</div>
		<footer class="logistica-planeacion__modal-footer logistica-planeacion__modal-footer--task">
			<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--danger logistica-planeacion__btn--modal" data-action="planeacion-delete-machine" hidden><?php esc_html_e( 'Eliminar máquina', 'logistica' ); ?></button>
			<div class="logistica-planeacion__modal-actions">
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--secondary logistica-planeacion__btn--modal" data-action="planeacion-close-machine-modal"><?php esc_html_e( 'Cancelar', 'logistica' ); ?></button>
				<button type="submit" class="logistica-planeacion__btn logistica-planeacion__btn--primary logistica-planeacion__btn--modal" data-planeacion-machine-submit><?php esc_html_e( 'Crear máquina', 'logistica' ); ?></button>
			</div>
		</footer>
	</form>
</dialog>
<?php endif; ?>

<?php if ( ! $show_planeacion_board ) : ?>
<dialog class="logistica-planeacion__modal logistica-planeacion__options-modal" data-planeacion-options-modal>
	<form class="logistica-planeacion__modal-form" data-planeacion-options-form>
		<header class="logistica-planeacion__modal-header">
			<h3><?php esc_html_e( 'Listas desplegables', 'logistica' ); ?></h3>
			<button type="button" class="logistica-planeacion__modal-close" data-action="planeacion-close-options-modal" aria-label="<?php esc_attr_e( 'Cerrar', 'logistica' ); ?>">&times;</button>
		</header>
		<div class="logistica-planeacion__modal-body">
			<p class="logistica-planeacion__field-hint"><?php esc_html_e( 'Escribe una opción por línea. Estas listas alimentan los campos Material, Montaje, Preparación de tintas, Planchas y Cumplimiento de metas.', 'logistica' ); ?></p>
			<div class="logistica-planeacion__options-grid">
				<label class="logistica-planeacion__form-span-2">
					<span><?php esc_html_e( 'Material (papel)', 'logistica' ); ?></span>
					<textarea rows="5" data-planeacion-options-field="papel_materials" placeholder="<?php esc_attr_e( "P1\nP2\nGCU\nOtro", 'logistica' ); ?>"></textarea>
				</label>
				<label>
					<span><?php esc_html_e( 'Montaje', 'logistica' ); ?></span>
					<textarea rows="5" data-planeacion-options-field="montaje" placeholder="<?php esc_attr_e( "OK\nBUSCAR", 'logistica' ); ?>"></textarea>
				</label>
				<label>
					<span><?php esc_html_e( 'Preparación de tintas', 'logistica' ); ?></span>
					<textarea rows="5" data-planeacion-options-field="prep_tinta"></textarea>
				</label>
				<label>
					<span><?php esc_html_e( 'Planchas', 'logistica' ); ?></span>
					<textarea rows="5" data-planeacion-options-field="planchas"></textarea>
				</label>
				<label>
					<span><?php esc_html_e( 'Cumplimiento de metas', 'logistica' ); ?></span>
					<textarea rows="5" data-planeacion-options-field="meta"></textarea>
				</label>
			</div>
		</div>
		<footer class="logistica-planeacion__modal-footer">
			<div class="logistica-planeacion__modal-actions logistica-planeacion__modal-actions--end">
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--secondary logistica-planeacion__btn--modal" data-action="planeacion-close-options-modal"><?php esc_html_e( 'Cancelar', 'logistica' ); ?></button>
				<button type="button" class="logistica-planeacion__btn logistica-planeacion__btn--primary logistica-planeacion__btn--modal" data-action="planeacion-save-field-options"><?php esc_html_e( 'Guardar listas', 'logistica' ); ?></button>
			</div>
		</footer>
	</form>
</dialog>
<?php endif; ?>

<script type="application/json" id="logistica-planeacion-bootstrap">
<?php
echo wp_json_encode(
	array(
		'semana_inicio' => $week_start,
		'today_ymd'     => wp_date( 'Y-m-d', null, new DateTimeZone( Logistica_User_Panel::PANEL_TIMEZONE ) ),
		'timezone'      => Logistica_User_Panel::PANEL_TIMEZONE,
		'machines'             => $machines,
		'custom_machine_slugs' => array_keys( Logistica_Print_Planning::get_custom_machines() ),
		'days'          => $days,
		'statuses'      => $statuses,
		'tamanos_base'  => Logistica_Print_Planning::TAMANOS_BASE,
		'minutes_base'  => Logistica_Print_Planning::MINUTES_BASE,
		'complexities'   => $complexities,
		'labor_types'    => $labor_types,
		'labor_defaults' => Logistica_Print_Planning::LABOR_DEFAULT_MINUTES,
		'labor_field_rules' => Logistica_Print_Planning::labor_field_rules(),
		'papel_materials' => $papel_materials,
		'field_options'   => $field_options,
		'day_hours'      => $day_hours,
		'day_types'      => $day_types,
		'holiday_settings' => Logistica_Settings::get_panel_holidays_client_config(),
		'festivo_dates'  => Logistica_Settings::get_festivo_dates_map( $panel_year - 1, $panel_year + 2 ),
	),
	JSON_UNESCAPED_UNICODE
);
?>
</script>
<?php logistica_admin_footer(); ?>
