50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
<?
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select * from ecmdocumenttemplates where id='".$_GET['template_id']."'"));
|
|
//print mysql_error();
|
|
$per=$r['documents_per'];
|
|
$format=$r['document_number_format_id'];
|
|
$date=$timedate->to_display($_GET['date'], $timedate->get_date_format(), "Y-m-d");
|
|
$exp=explode("-",$date);
|
|
if($per=="day")$daten=$date;
|
|
if($per=="month")$daten=$exp[0]."-".$exp[1];
|
|
if($per=="year")$daten=$exp[0];
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select number from ".$_GET['table']." where ".$_GET['date_field']." like '".$daten."%' order by number desc limit 1"));
|
|
$no=$r['number']+1;
|
|
//$number=$_GET['prefix']."/".$no."/".$exp[1]."/".$exp[0];
|
|
|
|
if($format[1]=="/")$sep="/";
|
|
elseif($format[1]==".")$sep=".";
|
|
elseif($format[1]=="-")$sep="-";
|
|
else $sep="";
|
|
if($format=="NR/D/M/Y")$sep="/";
|
|
if($format=="NR.D.M.Y")$sep=".";
|
|
if($format=="NR D/M/Y")$sep=" ";
|
|
if($format=="NR-D-M-Y")$sep="-";
|
|
if($format=="NRDMY")$sep="";
|
|
/*
|
|
if($per=="month")
|
|
{
|
|
$format=str_replace("D "," ",$format);
|
|
$format=str_replace("D-","",$format);
|
|
$format=str_replace("D/","",$format);
|
|
$format=str_replace("D.","",$format);
|
|
}
|
|
if($per=="year")
|
|
{
|
|
$format=str_replace("D "," ",$format);
|
|
$format=str_replace("D-","",$format);
|
|
$format=str_replace("M-","",$format);
|
|
$format=str_replace("D/","",$format);
|
|
$format=str_replace("M/","",$format);
|
|
$format=str_replace("D.","",$format);
|
|
$format=str_replace("M.","",$format);
|
|
}*/
|
|
$format=str_replace("NR",$no,$format);
|
|
$format=str_replace("Y",$exp[0],$format);
|
|
$format=str_replace("M",$exp[1],$format);
|
|
$format=str_replace("D",$exp[2],$format);
|
|
|
|
$number=$_GET['prefix'].$sep.$format;
|
|
if($_GET['show_number'])print $number;
|
|
else print $no;
|
|
?>
|