<?php // этот модуль необходимо делать тольео для крупных проектов, для небольшых описание пунктов меню и файлов меню лучше делать в init.php
$__functions['init'][]      ='_esmo_billing_admin_vars' ;
$__functions['boot_admin'][] ='_esmo_billing_admin_boot' ;
//$__functions['alert'][]   ='_esmo_billing_admin_alert' ;
$__functions['install'][]	='_esmo_billing_install_modul' ;



function _esmo_billing_admin_vars() //
{   //-----------------------------------------------------------------------------------------------------------------------------
	// описание переменных модуля
	//-----------------------------------------------------------------------------------------------------------------------------

	//-----------------------------------------------------------------------------------------------------------------------------
	// описание классов модуля
	//-----------------------------------------------------------------------------------------------------------------------------



	//----------------------------------------------------------------------------------------------------------------------
	// описание пунктов меню админа сайта
	//-----------------------------------------------------------------------------------------------------------------------
    $_SESSION['descr_clss'][210]['fields']['agent']=array('type'=>'indx_select','array'=>'ARR_members') ;
    $_SESSION['descr_clss'][210]['fields']['tarif']=array('type'=>'indx_select','array'=>'IL_tarif') ; // тип операции
    $_SESSION['descr_clss'][210]['list']['field']['agent']		        =array('title'=>'Агент') ;
    $_SESSION['descr_clss'][210]['list']['field']['tarif']		        =array('title'=>'Тариф') ;

    $_SESSION['descr_clss'][400]['name']='Денежная операция' ;
    $_SESSION['descr_clss'][400]['parent']=0 ;
    $_SESSION['descr_clss'][400]['fields']['c_data']=array('type'=>'timedata','is_edit'=>1,'datepicker'=>1,'data_format'=>'d.m.y') ;
    $_SESSION['descr_clss'][400]['fields']['typ']=array('type'=>'indx_select','array'=>'ARR_chet_operation_types') ; // тип операции
    $_SESSION['descr_clss'][400]['fields']['member_from']='int(11)' ;
    $_SESSION['descr_clss'][400]['fields']['member_to']='int(11)' ;
    $_SESSION['descr_clss'][400]['fields']['rs']='int(11)' ;
    $_SESSION['descr_clss'][400]['fields']['rs_from']='int(11)' ;
    $_SESSION['descr_clss'][400]['fields']['rs_to']='int(11)' ;
    $_SESSION['descr_clss'][400]['fields']['mo_id']='int(11)' ;   // id счета
    $_SESSION['descr_clss'][400]['fields']['tarif']=array('type'=>'indx_select','array'=>'IL_tarif') ; // тип операции
    $_SESSION['descr_clss'][400]['fields']['value_in']='float(10,2)' ; // остаток от предудущей операции
    $_SESSION['descr_clss'][400]['fields']['value']='float(10,2)' ; // сумма текущей операции
    $_SESSION['descr_clss'][400]['fields']['value_out']='float(10,2)' ; // остаток от текущей операции
    $_SESSION['descr_clss'][400]['fields']['submit']=array('type'=>'int(1)') ;  // операция подтверждена
    $_SESSION['descr_clss'][400]['fields']['status']='int(11)' ;
    $_SESSION['descr_clss'][400]['no_show_in_tree']=1 ;

    $_SESSION['descr_clss'][400]['list']['field']['pkey']=array('title'=>'id') ;
    $_SESSION['descr_clss'][400]['list']['field']['c_data']=array('title'=>'Дата') ;
    $_SESSION['descr_clss'][400]['list']['field']['member_from']=array('title'=>'Плательщик','on_view'=>'B2B_member_on_view') ;
    $_SESSION['descr_clss'][400]['list']['field']['member_to']=array('title'=>'Получатель','on_view'=>'B2B_member_on_view') ;
    $_SESSION['descr_clss'][400]['list']['field']['obj_name']=array('title'=>'Назначение') ;
    $_SESSION['descr_clss'][400]['list']['field']['obj_reffer']=array('title'=>'obj_reffer') ;
    $_SESSION['descr_clss'][400]['list']['field']['inv_id']=array('title'=>'inv_id') ;
    $_SESSION['descr_clss'][400]['list']['field']['tarif']=array('title'=>'Тариф') ;
    $_SESSION['descr_clss'][400]['list']['field']['value_in']=array('title'=>'До') ;
    $_SESSION['descr_clss'][400]['list']['field']['value']=array('title'=>'Сумма') ;
    $_SESSION['descr_clss'][400]['list']['field']['value_out']=array('title'=>'После') ;
    $_SESSION['descr_clss'][400]['list']['field']['submit']=array('title'=>'Операция подтверждена') ;
    $_SESSION['descr_clss'][400]['list']['field']['status']=array('title'=>'Статус') ;


    $_SESSION['descr_clss'][401]['name']='Расчетный счет' ;
    $_SESSION['descr_clss'][401]['parent']=0 ;
    $_SESSION['descr_clss'][401]['fields']['member_id']='int(11)' ;
    $_SESSION['descr_clss'][401]['fields']['typ']=array('type'=>'indx_select','array'=>'ARR_chet_types') ;
    $_SESSION['descr_clss'][401]['fields']['value']='float(10,2)' ;
    $_SESSION['descr_clss'][401]['fields']['tarif']=array('type'=>'indx_select','array'=>'IL_tarif') ; // тип операции

    $_SESSION['descr_clss'][401]['list']['field']['id']		        	=array('title'=>'Код.') ;
    $_SESSION['descr_clss'][401]['list']['field']['obj_name']		    =array('title'=>'Наименование') ;
    $_SESSION['descr_clss'][401]['list']['field']['member_id']		    =array('title'=>'member_id') ;
    $_SESSION['descr_clss'][401]['list']['field']['value']		    =array('title'=>'Сумма') ;
    $_SESSION['descr_clss'][401]['list']['field']['tarif']		    =array('title'=>'Тариф') ;
    $_SESSION['descr_clss'][401]['list']['field']['typ']		    =array('title'=>'Тип счета') ;

    
    $_SESSION['descr_clss'][402]['name']='Тарифный план' ;
    $_SESSION['descr_clss'][402]['parent']=20 ;
    $_SESSION['descr_clss'][402]['fields']=array('obj_name'=>'varchar(255)') ;
    $_SESSION['descr_clss'][402]['fields']['time_1']=array('type'=>'varchar(5)') ;
    $_SESSION['descr_clss'][402]['fields']['time_2']=array('type'=>'varchar(5)') ;
    $_SESSION['descr_clss'][402]['fields']['group_id']=array('type'=>'indx_select','array'=>'IL_groups') ;
    $_SESSION['descr_clss'][402]['fields']['price_1']='float(10,2)' ;
    $_SESSION['descr_clss'][402]['fields']['price_2']='float(10,2)' ;
    $_SESSION['descr_clss'][402]['fields']['price_3']='float(10,2)' ;
    $_SESSION['descr_clss'][402]['fields']['price_4']='float(10,2)' ;


    $_SESSION['descr_clss'][402]['child_to']=array(21) ;
    $_SESSION['descr_clss'][402]['parent_to']=array() ;
    $_SESSION['descr_clss'][402]['no_show_in_tree']=0 ; // не показывать объекты класса в дереве
    $_SESSION['descr_clss'][402]['icons']=_PATH_TO_BASED_CLSS_IMG.'/98.png' ;
    $_SESSION['descr_clss'][402]['list']['field']['id']		        	=array('title'=>'Код.') ;
    $_SESSION['descr_clss'][402]['list']['field']['enabled']			=array('title'=>'Сост.') ;
    $_SESSION['descr_clss'][402]['list']['field']['obj_name']			=array('title'=>'Название','td_class'=>'left') ;
    $_SESSION['descr_clss'][402]['list']['field']['time_1']          =array('title'=>'Время от') ;
    $_SESSION['descr_clss'][402]['list']['field']['time_2']            =array('title'=>'Время до') ;
    $_SESSION['descr_clss'][402]['list']['field']['group']              =array('title'=>'Группа') ;
    $_SESSION['descr_clss'][402]['list']['field']['price_1']			=array('title'=>'Агент: Стоимость допуска','td_class'=>'left') ;
    $_SESSION['descr_clss'][402]['list']['field']['price_2']			=array('title'=>'Агент: Стоимость недопуска','td_class'=>'left') ;
    $_SESSION['descr_clss'][402]['list']['field']['price_3']			=array('title'=>'Роялти: Стоимость допуска','td_class'=>'left') ;
    $_SESSION['descr_clss'][402]['list']['field']['price_4']			=array('title'=>'Роялти: Стоимость недопуска','td_class'=>'left') ;
    $_SESSION['descr_clss'][402]['details']=$_SESSION['descr_clss'][402]['list'] ;
    
    

}

function _esmo_billing_admin_boot($options)
{
    create_system_modul_obj('esmo_billing',$options) ;

}


function _esmo_billing_install_modul($DOT_root)
{   //регистрируем отчеты
     SETUP()->reg_report('Биллинг','aspmo_bill/report_bill_to.php') ;         //
     SETUP()->reg_report('Биллинг','aspmo_bill/report_bill_mo.php') ;         //

	$pattern=array() ;
    $pattern['table_title']		        = 	'Биллинг' ;
    $pattern['use_clss']		        = 	'1,400' ;
    $pattern['table_name']				= 	'obj_site_bill' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$DOT_root;
    create_table_by_pattern($pattern) ;

    $pattern=array() ;
    $pattern['table_title']		        = 	'Счета' ;
    $pattern['use_clss']		        = 	'1,401' ;
    $pattern['table_name']				= 	'obj_site_rs' ;
    $pattern['table_clss']				= 	101 ;
    $pattern['table_parent']			= 	$DOT_root;
    create_table_by_pattern($pattern) ;

    $id_list=SETUP_add_list_to_site_list(1,'Тарифы МО','tarif') ;

    $id_sect=SETUP_add_section_to_site_setting('Биллинг') ;
    SETUP_add_rec_to_site_setting($id_sect,"Стоимость допуска для клиента",50,'LS_bill_price_client') ;
    SETUP_add_rec_to_site_setting($id_sect,"Стоимость допуска для ЭСМО",5,'LS_pp_bill_price_esmo') ;

}




?>