diff -r fc60ef80a7ad -r 679bc22e37e2 fhiiqm/inc/vertragtab_ins.inc.php
--- a/fhiiqm/inc/vertragtab_ins.inc.php Wed Feb 27 09:43:08 2013 +0100
+++ b/fhiiqm/inc/vertragtab_ins.inc.php Tue Mar 26 15:41:01 2013 +0100
@@ -93,24 +93,38 @@
// Kosten
$retk = true;
- if ($vtr['kost'] && $vtr['bjahr']) // Kosten fuer mindestens Startjahr
+ if ($vtr['kost'] && ($vtr['bjahr'] || $vtr['bdat'])) // Kosten fuer mindestens Startjahr
{
+ if ($vtr['bdat'])
+ {
+ $jahr = new DateTime($vtr['bdat']);
+ $bjahr = $jahr->format('Y');
+ }
+ else $bjahr = $vtr['bjahr'];
+
// alle bisherigen Angaben loeschen
$sql = "DELETE FROM Vertrag_Kosten WHERE contract_ID = $cid";
$retdk = $dbc -> execute($sql);
if ($retdk)
{
$j=0;
- if ($vtr['ejahr'])
- $ejahr = $vtr['ejahr'];
- elseif ($vtr["cautoend"] && !$vtr['ejahr']) // automatische Vertragsverlaengerung und kein Endjahr angegeben
+ if ($vtr['ejahr'] || $vtr['edat'])
+ {
+ if ($vtr['ejahr']) $ejahr = $vtr['ejahr'];
+ else
+ {
+ $jahr = new DateTime($vtr['edat']);
+ $ejahr = $jahr->format('Y');
+ }
+ }
+ elseif ($vtr["cautoend"] && !$vtr['ejahr'] && !$vtr['edat']) // automatische Vertragsverlaengerung und kein Endjahr angegeben
$ejahr = date("Y");
else
$ejahr = null;
// if ($vtr['ejahr']) // Endjahr angegeben
if ($ejahr) // Endjahr angegeben
{
- for ($i=(int)$vtr['bjahr']; $i< (int)$ejahr +1; $i++)
+ for ($i=(int)$bjahr; $i< (int)$ejahr +1; $i++)
{
if ($vtr['kost'][$j])
{
@@ -128,7 +142,7 @@
{
// $kost = str_replace(',','.',$vtr['kost'][0]);
$kost = dbformat_wert($vtr['kost'][0]);
- $sql = "INSERT INTO Vertrag_Kosten (contract_ID,k_year,kosten) VALUES($cid,".(int)$vtr['bjahr'].",$kost)";
+ $sql = "INSERT INTO Vertrag_Kosten (contract_ID,k_year,kosten) VALUES($cid,".(int)$bjahr.",$kost)";
$retk = $dbc -> execute($sql);
}
}
@@ -136,5 +150,26 @@
}
}
-
+ // Vertragfile und Schlagwort
+ $retl = true;
+ if (is_array($vtr['cfname']) && count($vtr['cfname']) > 0)
+ {
+ // alle bisherigen Dokumente loeschen
+ $sql = "DELETE FROM Vertrag_File WHERE contract_ID = $cid";
+ $retdl = $dbc -> execute($sql);
+ if ($retdl)
+ {
+ foreach ($vtr['cfname'] as $key => $value)
+ {
+ if ($value)
+ {
+ if (!$vtr['swort'][$key] || $vtr['swort'][$key]<"!") $sw = null; else $sw = $vtr['swort'][$key];
+ if (substr($value,0,$len) != $cid . "_") $file = $cid . "_".$value; else $file = $value;
+ $sql = "INSERT INTO Vertrag_File (contract_ID,cf_filename,cf_schlagwort) VALUES ($cid,'$file','$sw')";
+ $retl = $retl && $dbc -> execute($sql);
+ }
+ }
+ if (!$retl) echo "error INSERT Vertrag_File: " . $dbc -> error . "
$sql
\n";
+ }
+ }
?>
\ No newline at end of file