<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_RUN_CUSTOM_SCRIPT';
$path_to_root = "..";
//include_once($path_to_root . "/includes/ui/items_cart.inc");
include($path_to_root . "/includes/session.inc");

page(_($help_context = "Run Custom Program"));

include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/admin/includes/ui/run_custom_program_ui.inc");



simple_page_mode(false);






//--------------------------------------------------------------------------------



if(isset($_POST['RUN_CUSTOM_PROGRAM']))
{
    $custom_program_log_folder_path = $path_to_root.'/tmp/custom_program_logs/';

    if (!file_exists($custom_program_log_folder_path))
    {
        create_folder_index_file($custom_program_log_folder_path);
    }
    
    run_manual_program($_POST['program_name'], $path_to_root);
    
}





//----------------------------------------------------------------------------------

//$result = get_all_item_units(check_value('show_inactive'));

$_POST['custom_script'] = null;

start_form();

br(2);

cp_display_run_custom_program_edit_controls();

br(2);

$program_name = "";
if(isset($_POST['program_name'])){
    $program_name = $_POST['program_name'];
}
cp_display_custom_edit_controls($program_name);

br(2);

submit_center("RUN_CUSTOM_PROGRAM", "Run Custom Program");

br(2);




end_form();

end_page();

?>
