<?php

/* * ********************************************************************
 * ********************************************************************* */
$page_security = 'SA_PROJECT_TRANSVIEW';
$path_to_root = "../..";
include_once($path_to_root . "/includes/db_pager.inc");
include($path_to_root . "/includes/session.inc");
$js = "";
if ($SysPrefs->use_popup_windows)
    $js .= get_js_open_window(900, 500);
if (user_use_date_picker())
    $js .= get_js_date_picker();

page(_($help_context = "Projects List"), @$_REQUEST['popup'], false, "", $js);

include_once($path_to_root . "/includes/date_functions.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 . "/inventory/includes/db/item_list_db.inc");


//include_once($path_to_root . "/projects/includes/db/projects_db.inc");
include_once($path_to_root . "/projects/includes/db/projects_list_db.inc");


function edit_link($row){
    return '<a href="#" onclick="pass_to_parent(\''.$row['project_id'].'\')">Select</a>';
}


start_form();

start_table(TABLESTYLE_NOBORDER,"width=98%");
start_row();
echo '<td align="center" colspan=5>&nbsp;</td>';
end_row();

start_row();
text_cells_ex(_('Description').' :', 'description', 35, 200);
text_cells_ex(_('Code').' :', 'code', 35, 50);
text_cells_ex(_('Project Id').' :', 'project_id', 10);
end_row();


start_row();
value_list_cells("Department", 'department_id', "DEPARTMENTS", null, '', true);
system_users_list_cells("Project Manager :", 'project_manager_id', null, '', true);
customer_list_cells('Customer:', 'customer_id', null, '', true);
end_row();


start_row();

value_list_cells("Status :", 'status_id', "PROJECT_STATUS", null, '', true);
submit_cells('SearchOrders', _("Search"),'',_('Search'), 'default');
end_row();


        
//start_row();
//submit_cells('SearchItem', _("Search"), '', _('Select documents'), 'default');
//end_row();

start_row();

end_row();
end_table(1);

//$sql = get_asset_advance_search_sql($_POST['id'], $_POST['code'],$_POST['description'], $_POST['hired'], 
//                                    $_POST['group_id'],$_POST['subgroup_id'],$_POST['category'], $_POST['rate_category'], 
//                                    $_POST['make'], $_POST['model'], $_POST['serial_no'], $_POST['type']);

$sql = get_projects_advance_search_sql($_POST['project_id'], $_POST['code'],$_POST['description'], $_POST['department_id'], 
                                    $_POST['project_manager_id'],$_POST['customer_id'],$_POST['status_id']);

$cols = array(
    _('Id'),
    _('Description'),
    _('Code'),
    _('Department'),
    _('Project Manager'),
    _('Customer'),
    
    
	array('insert' => true, 'fun' => 'edit_link')
);

//if(isset($_GET['popup'])){
//    array_append($cols, array(
//        array('insert' => true, 'fun' => 'edit_link'),
//    ));
//}
 
$table = & new_db_pager('item_tbl', $sql, $cols);
$table->width = "98%";
display_db_pager($table);

end_form();

if(isset($_GET['popup'])){
    echo get_js_parent_passing_item($_GET['parent']);
}
end_page();