<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_PROJECT_GALLERY';

$path_to_root = "..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
//include_once($path_to_root . "/inventory/includes/inventory_db.inc");
include_once($path_to_root . "/projects/includes/db/project_sites_db.inc");
include_once($path_to_root . "/dashboard/includes/ui/project_gallery_ui.inc");
include_once($path_to_root . "/dashboard/includes/db/upload_project_gallery_images_db.inc");


$js = '';

if (user_use_date_picker()) {
    
        $js .= get_js_date_picker();
}

if(isset($_GET['project_id'])){
    $_POST['project_id'] = $_GET['project_id'];
}

page(_($help_context = "Project Gallery"),false,false,"",$js);

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

check_db_has_projects(_("There are no projects defined in the system."));

simple_page_mode(true);
//---------------------------------------------------------------------------------------------------




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

//if ($Mode == 'Delete')
//{
//	//the link to delete a selected record was clicked
//	delete_site($_POST['project_id'], $selected_id);
//	display_notification(_("The selected task has been deleted."));
//	$Mode = 'RESET';
//}

if ($Mode == 'RESET')
{
	$selected_id = -1;
}

//--------------------------------------------------------------------------------------------------------
//$tasks = get_task($_POST['project_id']);

global $Ajax;

start_form();

br(2);
    
    
$Ajax->activate('section_id');

start_table(TABLESTYLE_NOBORDER);
    start_row();
        project_list_cells(_("Project:"), 'project_id', null,   _('Select a Project'), true);

        $project_id = get_post('project_id');
    end_row();
end_table();

start_table(TABLESTYLE_NOBORDER);
    start_row();
    date_cells("From Date: ", 'from_date', '', null, -90, 0, 0, null, true);
    date_cells("To Date: ", 'to_date', '', null, 0, 0, 0, null, true);
    project_sections_list_cells("Section: ", 'section_id', $_POST['project_id'], null, '', true);


    end_row();
end_table();

br();

$Ajax->activate('price_table');
div_start('price_table');

if($_POST['project_id']>0){
    display_project_gallery_images($_POST['project_id'], $_POST['section_id'], $_POST['from_date'], $_POST['to_date']);
}
else{
    display_note("Please select a project.");
}



div_end();

br(2);

end_form();
end_page(@$_GET['popup'], false, false);
	
?>
