Пример #1
0
             $vars[$name] = $_POST[$value];
         }
     }
 }
 $doc->parse($vars);
 $name = date("YmdHi") . $fname;
 $doc->prepsave("{$name}");
 $pfad = $_POST['pfad'];
 copy('tmp/' . $name, "dokumente/" . $_SESSION["dbname"] . "{$pfad}/{$name}");
 $dbfile = new document();
 $dbfile->setDocData("descript", "Dokumentvorlage: " . $docdata["document"]["vorlage"] . "\n" . $docdata["document"]["beschreibung"]);
 $dbfile->setDocData("name", $name);
 $dbfile->setDocData("pfad", $pfad);
 $rc = $dbfile->saveDocument();
 //$doc->clean();
 $cdata["id"] = mknewTelCall();
 $cdata["Datum"] = date("d.m.Y");
 $cdata["Date"] = date("d.m.Y");
 $cdata["Zeit"] = date("H:i");
 $cdata["Time"] = date("H:i");
 $cdata["datei"] = 1;
 $cdata["cause"] = $docdata["document"]["vorlage"];
 $cdata["c_cause"] = $docdata["document"]["beschreibung"];
 $cdata["CID"] = $pid ? $pid : $fid;
 $cdata["Kontakt"] = "D";
 $cdata["bezug"] = 0;
 $cdata["CRMUSER"] = $_SESSION["loginCRM"];
 updCall($cdata);
 documenttotc($cdata["id"], $dbfile->id);
 echo "Dokument erstellt";
 exit;
Пример #2
0
function saveTermin($data)
{
    if (!$data["tid"]) {
        $termid = newTermin();
    } else {
        $termid = $data["tid"];
        $sql = "delete from terminmember where termin={$termid}";
        $rc = $_SESSION['db']->query($sql);
        $sql = "delete from termdate where termid={$termid}";
        $rc = $_SESSION['db']->query($sql);
    }
    if (!$termid) {
        return false;
    } else {
        if (!$data["bisdat"]) {
            $data["bisdat"] = $data["vondat"];
        }
        $von = mktime(0, 0, 0, substr($data["vondat"], 3, 2), substr($data["vondat"], 0, 2), substr($data["vondat"], 6, 4));
        $bis = mktime(0, 0, 0, substr($data["bisdat"], 3, 2), substr($data["bisdat"], 0, 2), substr($data["bisdat"], 6, 4));
        //Bisdatum nicht kleiner Vondatum
        if ($bis < $von) {
            $bis = $von;
        }
        //Bisdatum nicht grösser Vondatum, dann biszeit>=vonzeit
        if (($bis == $von || $data["repeat"] != "0") && $data["bis"] < $data["von"]) {
            $data["bis"] = $data["von"];
        }
        $sql = "update termine set cause='" . $data["cause"] . "',kategorie=" . $data["kategorie"] . ",c_cause='" . $data["c_cause"];
        $sql .= "',starttag='" . date("Y-m-d", $von) . "',stoptag='" . date("Y-m-d", $bis) . "',startzeit='" . $data["von"] . "',stopzeit='" . $data["bis"] . "',";
        $sql .= "repeat=" . $data["repeat"] . ",ft='" . $data["ft"] . "',uid=" . $data["uid"] . ",privat='" . ($data["privat"] == 1 ? 't' : 'f') . "', ";
        //$sql.="syncid=".$data["syncid"].", ";
        // echtes Datum eintragen, schadet mal nicht und wird künfig verwendet.
        $sql .= "start='" . date("Y-m-d H:i:00", $von . " " . $data["von"]) . "', stop='" . date("Y-m-d H:i:00", $bis . " " . $data["bis"]) . "' ";
        $sql .= ",location='" . $data["location"] . "' ";
        $sql .= " where id=" . $termid;
        $rc = $_SESSION['db']->query($sql);
        if ($rc) {
            $year = date("Y", $von);
            $ft = feiertage($year);
            $ftk = array_keys($ft);
            $idx = 0;
            while ($bis >= $von) {
                if (date("Y", $von) != $year) {
                    $year = date("Y", $von);
                    $ft = feiertage($year);
                    $ftk = array_keys($ft);
                }
                $sql = "insert into termdate (termid,tag,monat,jahr,kw,idx) values (";
                $sql .= "{$termid},'" . date("d", $von) . "','" . date("m", $von) . "'," . date("Y", $von) . "," . strftime("%V", $von) . "," . $idx . ")";
                if ($data["ft"] && date("w", $von) != 6 && date("w", $von) != 0 && !in_array($von, $ftk) || !$data["ft"] || $von == $bis) {
                    $rc = $_SESSION['db']->query($sql);
                }
                switch ($data["repeat"]) {
                    case '0':
                    case '1':
                        $von += 60 * 60 * 24;
                        break;
                    case '2':
                        $von += 60 * 60 * 24 * 2;
                        break;
                    case '7':
                        $von += 60 * 60 * 24 * 7;
                        break;
                    case '14':
                        $von += 60 * 60 * 24 * 14;
                        break;
                    case '30':
                        $von = mktime(0, 0, 0, date("m", $von) + 1, date("d", $von), date("Y", $von));
                        break;
                    case '365':
                        $von = mktime(0, 0, 0, date("m", $von), date("d", $von), date("Y", $von) + 1);
                        break;
                    default:
                        $bis = mktime(0, 0, 0, 12, 31, 2100);
                }
                $idx++;
            }
            if ($data["user"]) {
                foreach ($data["user"] as $teiln) {
                    $nr = substr($teiln, 1);
                    $tab = substr($teiln, 0, 1);
                    $sql = "insert into terminmember (termin,member,tabelle) values (";
                    $sql .= $termid . ",{$nr},'{$tab}')";
                    $rc = $_SESSION['db']->query($sql);
                    if ($tab != "G" && $tab != "E") {
                        $tid = mknewTelCall();
                        $nun = date2db($data["vondat"]) . " " . $data["von"] . ":00";
                        $sql = "update telcall set cause='" . $data["grund"];
                        $sql .= "',caller_id={$nr},calldate='{$nun}',termin_id={$termid},c_long='" . $data["c_cause"];
                        $sql .= "',employee='" . $_SESSION["loginCRM"] . "',kontakt='X',bezug=0 where id={$tid}";
                        $rc = $_SESSION['db']->query($sql);
                        if (!$rs) {
                            $rs = -1;
                        }
                    }
                }
            }
        }
    }
}