<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*****************************************************************************
 * The contents of this file are subject to the RECIPROCAL PUBLIC LICENSE
 * Version 1.1 ("License"); You may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://opensource.org/licenses/rpl.php. Software distributed under the
 * License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
 * either express or implied.
 *
 * You may:
 * a) Use and distribute this code exactly as you received without payment or
 *    a royalty or other fee.
 * b) Create extensions for this code, provided that you make the extensions
 *    publicly available and document your modifications clearly.
 * c) Charge for a fee for warranty or support or for accepting liability
 *    obligations for your customers.
 *
 * You may NOT:
 * a) Charge for the use of the original code or extensions, including in
 *    electronic distribution models, such as ASP (Application Service
 *    Provider).
 * b) Charge for the original source code or your extensions other than a
 *    nominal fee to cover distribution costs where such distribution
 *    involves PHYSICAL media.
 * c) Modify or delete any pre-existing copyright notices, change notices,
 *    or License text in the Licensed Software
 * d) Assert any patent claims against the Licensor or Contributors, or
 *    which would in any way restrict the ability of any third party to use the
 *    Licensed Software.
 *
 * You must:
 * a) Document any modifications you make to this code including the nature of
 *    the change, the authors of the change, and the date of the change.
 * b) Make the source code for any extensions you deploy available via an
 *    Electronic Distribution Mechanism such as FTP or HTTP download.
 * c) Notify the licensor of the availability of source code to your extensions
 *    and include instructions on how to acquire the source code and updates.
 * d) Grant Licensor a world-wide, non-exclusive, royalty-free license to use,
 *    reproduce, perform, modify, sublicense, and distribute your extensions.
 *
 * The Original Code is: CommuniCore
 *                       Olavo Farias
 *                       2006-04-7 olavo.farias@gmail.com
 *
 * The Initial Developer of the Original Code is CommuniCore.
 * Portions created by CommuniCore are Copyright (C) 2005 CommuniCore Ltda
 * All Rights Reserved.
 ********************************************************************************/
/*******************************************************************************
 * Layout definition for EcmDocuments
 *******************************************************************************/
require_once("modules/EcmDocuments/dirstree.php");
$za="select treeread from users where id='".$_SESSION['authenticated_user_id']."'";
$wy=mysql_query($za);
$ro=mysql_fetch_array($wy);
$treeread=$ro['treeread'];

$za="select assigned_user_id from ecmdocuments where id='".$_GET['record']."'";
$wy=mysql_query($za);
$ro=mysql_fetch_array($wy);
$assigned_user_id=$ro['assigned_user_id'];
$za="select id from ecmdocuments where iddir='".$_GET['record']."'";
$wy=mysql_query($za);
$katalogi_liczba=mysql_num_rows($wy);
$za="select * from ecmdocuments_permissions where iddir='".$_GET['record']."' and userid='".$_SESSION['authenticated_user_id']."'";
$wy=mysql_query($za);
$ro=mysql_fetch_array($wy);
$add=$ro['add'];
error_reporting(E_ALL);
if($add==1 || check_is_admin($_SESSION['authenticated_user_id']) || $assigned_user_id==$_SESSION['authenticated_user_id'] || 
($treeread && ACLController::checkAccess('EcmDocuments', 'list', true)))$top_buttons='top_buttons';
else $top_buttons='';
if($katalogi_liczba==0)
{
$layout_defs['EcmDocuments'] = array(
    'subpanel_setup' => array(
	/*
		'ecmdocuments' => array(
			'order' => 10,
			'module' => 'EcmDocuments',
			'sort_order' => 'asc',
			'sort_by' => 'no',
			'subpanel_name' => 'default-ecmdocuments',
			'get_subpanel_data' => 'ecmdocuments',
			'add_subpanel_data' => 'iddir',
			'title_key' => 'LBL_ECMDOCUMENTS_DASHLET_TITLE',
		),*/
		'ecmdocs' => array(
			'order' => 20,
			'module' => 'EcmDocs',
			'sort_order' => 'asc',
			'sort_by' => 'name',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'ecmdocs',
			'add_subpanel_data' => 'ecmdoc_id',
			'title_key' => 'LBL_ECMDOCUMENTS_DASHLET_FILES_TITLE',
			$top_buttons => array(
			array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
        	array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'ecmcontracts' => array(
			'order' => 30,
			'module' => 'EcmContracts',
			'sort_order' => 'asc',
			'sort_by' => 'name',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'ecmcontracts',
			'add_subpanel_data' => 'ecmcontract_id',
			'title_key' => 'LBL_CONTRACTS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'ecmcorrespondenceins' => array(
			'order' => 40,
			'module' => 'EcmCorrespondenceIns',
			'sort_order' => 'asc',
			'sort_by' => 'name',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'ecmcorrespondenceins',
			'add_subpanel_data' => 'ecmcorrespondencein_id',
			'title_key' => 'LBL_CORRESPONDENCES_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
 			'refresh_page'=>1,
		),
		'ecmcorrespondenceouts' => array(
			'order' => 50,
			'module' => 'EcmCorrespondenceOuts',
			'sort_order' => 'asc',
			'sort_by' => 'name',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'ecmcorrespondenceouts',
			'add_subpanel_data' => 'ecmcorrespondenceout_id',
			'title_key' => 'LBL_CORRESPONDENCESOUT_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
 			'refresh_page'=>1,

		),
		'emailins' => array(
			'order' => 70,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Emails',
			'subpanel_name' => 'ForEcmDocumentsIn',
			'get_subpanel_data' => 'emails',
			'add_subpanel_data' => 'email_id',
			'title_key' => 'LBL_EMAILINS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'emailouts' => array(
			'order' => 170,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Emails',
			'subpanel_name' => 'ForEcmDocumentsOut',
			'get_subpanel_data' => 'emails',
			'add_subpanel_data' => 'email_id',
			'title_key' => 'LBL_EMAILOUTS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'ecminvoiceins' => array(
			'order' => 80,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'EcmInvoiceIns',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'ecminvoiceins',
			'add_subpanel_data' => 'ecminvoicein_id',
			'title_key' => 'LBL_ECMINVOICES_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'ecminvoiceouts' => array(
			'order' => 90,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'EcmInvoiceOuts',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'ecminvoiceouts',
			'add_subpanel_data' => 'ecminvoiceout_id',
			'title_key' => 'LBL_ECMINVOICESOUT_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'contacts' => array(
			'order' => 100,
			'module' => 'Contacts',
			'sort_order' => 'asc',
			'sort_by' => 'last_name, first_name',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'contacts',
			'add_subpanel_data' => 'contact_id',
			'title_key' => 'LBL_CONTACTS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'accounts' => array(
			'order' => 110,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Accounts',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'accounts',
			'add_subpanel_data' => 'account_id',
			'title_key' => 'LBL_ACCOUNTS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'calls' => array(
			'order' => 120,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Calls',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'calls',
			'add_subpanel_data' => 'call_id',
			'title_key' => 'LBL_CALLS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'meetings' => array(
			'order' => 130,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Meetings',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'meetings',
			'add_subpanel_data' => 'meeting_id',
			'title_key' => 'LBL_MEETINGS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'tasks' => array(
			'order' => 140,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Tasks',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'tasks',
			'add_subpanel_data' => 'task_id',
			'title_key' => 'LBL_TASKS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'notes' => array(
			'order' => 150,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Notes',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'notes',
			'add_subpanel_data' => 'note_id',
			'title_key' => 'LBL_NOTES_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
    ),
);
}
else
{
$layout_defs['EcmDocuments'] = array(
    'subpanel_setup' => array(
	/*
		'ecmdocuments' => array(
			'order' => 10,
			'module' => 'EcmDocuments',
			'sort_order' => 'asc',
			'sort_by' => 'no',
			'subpanel_name' => 'default-ecmdocuments',
			'get_subpanel_data' => 'ecmdocuments',
			'add_subpanel_data' => 'iddir',
			'title_key' => 'LBL_ECMDOCUMENTS_DASHLET_TITLE',
		),*/
		'contacts' => array(
			'order' => 20,
			'module' => 'Contacts',
			'sort_order' => 'asc',
			'sort_by' => 'last_name, first_name',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'contacts',
			'add_subpanel_data' => 'contact_id',
			'title_key' => 'LBL_CONTACTS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'accounts' => array(
			'order' => 30,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Accounts',
			'subpanel_name' => 'default',
			'get_subpanel_data' => 'accounts',
			'add_subpanel_data' => 'account_id',
			'title_key' => 'LBL_ACCOUNTS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'calls' => array(
			'order' => 40,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Calls',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'calls',
			'add_subpanel_data' => 'call_id',
			'title_key' => 'LBL_CALLS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'meetings' => array(
			'order' => 50,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Meetings',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'meetings',
			'add_subpanel_data' => 'meeting_id',
			'title_key' => 'LBL_MEETINGS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'tasks' => array(
			'order' => 60,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Tasks',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'tasks',
			'add_subpanel_data' => 'task_id',
			'title_key' => 'LBL_TASKS_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
		'notes' => array(
			'order' => 70,
			'sort_order' => 'desc',
			'sort_by' => 'name',
			'module' => 'Notes',
			'subpanel_name' => 'ForEcmDocuments',
			'get_subpanel_data' => 'notes',
			'add_subpanel_data' => 'note_id',
			'title_key' => 'LBL_NOTES_SUBPANEL_TITLE',
			$top_buttons => array(
				array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect'),
				array('widget_class' => 'SubPanelTopCreateButton'),
			),
			'refresh_page'=>1,
		),
	)
);
}
?>
