<?php
//USEREXIT file
//Code placed here modifies standard odb functionality
//MAPS
if($variable_array['sysGroupBy']=='maps')
{
$variable_array['Show Map']='map.php?';
$variable_array['Show Map'].='odb_title='.$variable_array['Map Title'];
$variable_array['Show Map'].='&odb_search='.$variable_array['Map Range'];
if($variable_array['Show Icons'])
$variable_array['Show Map'].='&odb_icon_field_name=Icon';
$variable_array['Show Map'].='&odb_map='.$variable_array['Map Background'];
$variable_array['Show Map'].='&odb_colorset='.$variable_array['Map Colorset'];
$variable_array['Show Map'].='&odb_value_field_name='.$variable_array['Map Value Field'];
$variable_array['Show Map'].='&odb_region_field_name='.$variable_array['Map Region Field'];
$variable_array['Show Background']='index.php?';
$variable_array['Show Background'].='odb_run=map';
$variable_array['Show Background'].='&odb_title='.$variable_array['Map Title'];
$variable_array['Show Background'].='&odb_search='.$variable_array['Map Range'];
if($variable_array['Show Icons'])
$variable_array['Show Background'].='&odb_icon_field_name=Icon';
$variable_array['Show Background'].='&odb_map='.$variable_array['Map Background'];
$variable_array['Show Background'].='&odb_colorset='.$variable_array['Map Colorset'];
$variable_array['Show Background'].='&odb_value_field_name='.$variable_array['Map Value Field'];
$variable_array['Show Background'].='&odb_region_field_name='.$variable_array['Map Region Field'];
}
//MAILING
if($variable_array['sysGroupBy']=='mailing')
{
if($variable_array['Send']) //button field
{
$tmp_result_array=search($variable_array['Range'].' -mailing');
if(count($tmp_result_array)) //result non-empty
{
reset($tmp_result_array);
while(list($tmp,$tmp_result)=each($tmp_result_array))
{
$tmp_variable_array=line2array($tmp_result);
$mail_subject=fill_variables($variable_array['Subject'],$tmp_variable_array);
$mail_body=fill_variables($variable_array['Body'],$tmp_variable_array);
$mail_cc=fill_variables($variable_array['CC'],$tmp_variable_array);
$mail_to=fill_variables($variable_array['To'],$tmp_variable_array);
send_email($mail_to,$mail_subject,$mail_body,$mail_cc);
}
}
}
}
/*
if($variable_array['Ready']) //button field
{
$variable_array['Status']='Ready';
$variable_array['Date OK']=1;
}
*/
//~ if($variable_array['sysGroupBy']=='crinfo')
//~ $variable_array['MyBag']='crinfo';
//~ if($variable_array['sysGroupBy']=='accessabilitycard')
//~ $variable_array['MyBag']='pers_'.purename($variable_array['Translator Code']);
//CR Status Days Count
//~ if($variable_array['sysGroupBy']=='crinfo' and $variable_name=='CR Status')
//~ {
//~ $reference_date=$variable_array['CR Submitted Date'];
//~ if(strlen($reference_date)==8)
//~ $variable_array['Days To '.$variable_array[$variable_name]]=floor((time()-mktime(0,0,0,substr($reference_date,4,2),substr($reference_date,6,2),substr($reference_date,0,4)))/3600/24);
//~ }
/* Delay count
if($variable_array['sysGroupBy']=='test')
{
$old_reference_date=$old_variable_array['My date'];
$new_reference_date=$variable_array['My date'];
$number_of_days_field_name='Late';
if($old_reference_date and $new_reference_date)
{
if($old_reference_date!=$new_reference_date)
$variable_array[$number_of_days_field_name]=$old_variable_array[$number_of_days_field_name]+round((mktime(12,0,0,substr($new_reference_date,4,2),substr($new_reference_date,6,2),substr($new_reference_date,0,4))-mktime(12,0,0,substr($old_reference_date,4,2),substr($old_reference_date,6,2),substr($old_reference_date,0,4)))/3600/24,0);
}
else
$variable_array[$number_of_days_field_name]=0;
if($variable_array[$number_of_days_field_name]==0)
$variable_array[$number_of_days_field_name]=' ';
}
*/
//produce documents
//searching for the first important fields
$first_important_variable_name='';
$second_important_variable_name='';
$third_important_variable_name='';
$variable_array2=load_config($variable_array['sysGroupBy']);
reset($variable_array2);
while(list($variable_name,$variable_description)=each($variable_array2))
{
if($variable_description['hl']==1 and $first_important_variable_name=='')
$first_important_variable_name=$variable_name;
elseif($variable_description['hl']==1 and $second_important_variable_name=='')
$second_important_variable_name=$variable_name;
elseif($variable_description['hl']==1)
{
$third_important_variable_name=$variable_name;
break;
}
}
//if($variable_array[$first_important_variable_name]!=$old_variable_array[$first_important_variable_name]
//or $variable_array[$second_important_variable_name]!=$old_variable_array[$second_important_variable_name]
//or $variable_array[$third_important_variable_name]!=$old_variable_array[$third_important_variable_name])
{
reset($variable_array2);
while(list($variable_name,$variable_description)=each($variable_array2))
{
if($variable_description['template']=='document')
{
$document_template=$variable_name; //name of the field is also name of the template
$tmp_result_array=search('sysGroupBy=documenttemplates [Document Template Name='.$document_template.'] [Document Template File]');
if(count($tmp_result_array))
{
$template=read($tmp_result_array[0],'Document Template File');
$tmp_result_array2=array();//search('['.$first_important_variable_name.'='.$variable_array[$first_important_variable_name].'] ['.$second_important_variable_name.'='.$variable_array[$second_important_variable_name].'] ['.$third_important_variable_name.'='.$variable_array[$third_important_variable_name].']');
$tmp_result_array2[0]=array2line($variable_array);
$variable_array[$variable_name]=create_document(linkname($document_template).'-'.linkname($variable_array[$first_important_variable_name]).'-'.linkname($variable_array[$second_important_variable_name]),$template,$tmp_result_array2);
}
}
}
}
?>