예제 #1
0
function getMailTpl($id, $KontaktTO = '')
{
    $data = getOneMailVorlage($id);
    $Subject = $data["cause"];
    $BodyText = $data["c_long"];
    if ($KontaktTO != '') {
        $user = getUserStamm($_SESSION["loginCRM"]);
        if (substr($KontaktTO, 0, 1) == "K") {
            include "inc/persLib.php";
            $empf = getKontaktStamm(substr($KontaktTO, 1));
            $tmp = getFirmaCVars($empf["cp_cv_id"]);
            if ($tmp) {
                foreach ($tmp as $key => $val) {
                    $empf[$key] = $val;
                }
            }
            //} else if (substr($KontaktTO,0,1)=="C") {
        } else {
            if (substr($KontaktTO, 0, 1) == "S") {
                $empf = getShipStamm(substr($KontaktTO, 1), 'C', True);
                // <- Da noch mal ran. Hart Kundenstamm
            } else {
                if ($KontaktTO) {
                    $empf = getFirmenStamm(substr($KontaktTO, 1), true, substr($KontaktTO, 0, 1));
                }
            }
        }
        foreach ($user as $key => $val) {
            $empf['employee' . strtolower($key)] = $val;
        }
        preg_match_all("/%([A-Z0-9_]+)%/iU", $BodyText, $ph, PREG_PATTERN_ORDER);
        $ph = array_slice($ph, 1);
        if ($ph[0]) {
            $anrede = false;
            foreach ($ph[0] as $x) {
                $y = $empf[$x];
                if ($x == "cp_greeting") {
                    $anrede = $y;
                }
                $BodyText = preg_replace("/%" . $x . "%/i", $y, $BodyText);
            }
            if ($anrede == "Herr") {
                $BodyText = preg_replace("/%cp_anrede%/", "r", $BodyText);
            } else {
                if ($anrede) {
                    $BodyText = preg_replace("/%cp_anrede%/", "", $BodyText);
                }
            }
        }
    }
    //$MailSign=ereg_replace("\r","",$user["mailsign"]);
    $Response = array('subject' => $Subject, 'bodytxt' => $BodyText);
    //." \n".$MailSign);
    echo json_encode($Response);
}
예제 #2
0
     $data = getShipStamm($_GET["sid"], $Q, $_POST["complete"]);
     //$anrede="Firma";
     if ($data) {
         $anrede = $data["shiptogreeting"];
         $name = $data["shiptoname"];
         $name2 = $data["shiptodepartment_1"];
         $kontakt = $data["shiptocontact"];
         $strasse = $data["shiptostreet"];
         $land = $data["shiptocountry"];
         $plz = $data["shiptozipcode"];
         $ort = $data["shiptocity"];
         $telefon = $data["shiptophone"];
         $fax = $data["shiptofax"];
         $email = $data["shiptoemail"];
     }
     $data = getFirmaCVars($data["trans_id"]);
     $name1 = $name;
 } else {
     $id = $_GET["fid"];
     $dest = "fid=" . $_GET["fid"];
     $data = getFirmenStamm($_GET["fid"], true, $Q);
     $anrede = $data["greeting"];
     $name = $data["name"];
     $name1 = $name;
     $name2 = $data["department_1"];
     $kontakt = $data["contact"];
     $strasse = $data["street"];
     $land = $data["country"];
     $plz = $data["zipcode"];
     $ort = $data["city"];
     $telefon = $data["phone"];
예제 #3
0
function getFirmenStamm($id, $ws = true, $tab = 'C', $cvar = true)
{
    if ($tab == "C") {
        // Umsätze holen
        $sql = "select sum(amount) from oe where customer_id={$id} and quotation='f' and closed = 'f'";
        $rs = $_SESSION['db']->getOne($sql);
        $oa = $rs["sum"];
        $sql = "select sum(amount) from ar where customer_id={$id} and amount<>paid";
        $rs = $_SESSION['db']->getOne($sql);
        $op = $rs["sum"];
        $sql = "select C.*,E.name as verkaeufer,EMP.name as bearbeiter,B.description as kdtyp,B.discount as typrabatt,P.pricegroup,";
        $sql .= "L.lead as leadname,BL.bundesland,T.terms_netto,LA.description as language from customer C ";
        $sql .= "left join employee E on C.salesman_id=E.id left join employee EMP on C.employee=EMP.id ";
        $sql .= "left join business B on B.id=C.business_id left join bundesland BL on BL.id=C.bland ";
        $sql .= "left join payment_terms T on T.id=C.payment_id left join pricegroup P on P.id=C.klass ";
        $sql .= "left join leads L on C.lead=L.id left join language LA on LA.id = C.language_id ";
        $sql .= "where C.id={$id}";
    } else {
        if ($tab == "V") {
            // Umsätze holen
            $sql = "select sum(amount) as summe from ap where vendor_id={$id} and amount<>paid";
            $rs = $_SESSION['db']->getOne($sql);
            $op = $rs["summe"];
            $sql = "select sum(amount) from oe where vendor_id={$id} and quotation='f' and closed = 'f'";
            $rs = $_SESSION['db']->getOne($sql);
            $oa = $rs["sum"];
            $sql = "select C.*,E.name as verkaeufer,EMP.name as bearbeiter,B.description as kdtyp,B.discount as typrabatt,BL.bundesland,";
            $sql .= "L.lead as leadname,LA.description as language from vendor C left join employee EMP on C.employee=EMP.id ";
            $sql .= "left join employee E on C.salesman_id=E.id left join business B on B.id=C.business_id ";
            $sql .= "left join language LA on LA.id = C.language_id left join leads L on C.lead=L.id ";
            $sql .= "left join bundesland BL on BL.id=C.bland ";
            $sql .= "where C.id={$id}";
        } else {
            return false;
        }
    }
    $row = $_SESSION['db']->getOne($sql);
    // Rechnungsanschrift
    if (!$row) {
        return false;
    } else {
        /* history_erp wird wohl nicht richtig gepflegt, also erst einmal raus
           if ($row["mtime"]=="") {
               $sql = "select * from history_erp where trans_id = $id and snumbers like '%rnumber_%' order by itime desc limit 1";
               $rs2 = $_SESSION['db']->getOne($sql);  // Rechnungsanschrift
               if ($rs2) if ($rs2["itime"]<>$row["itime"])
                  $row["mtime"] = $rs2["itime"];
               $row["modemployee"] = $rs2["employee_id"];
           } else {
               $row["modemployee"] = $row["employee"];
           }*/
        $row["modemployee"] = $row["employee"];
        if ($row["konzern"]) {
            $sql = "select name from %s where id = %d";
            if ($tab == "C") {
                $krs = $_SESSION['db']->getOne(sprintf($sql, "customer", $row["konzern"]));
            } else {
                $krs = $_SESSION['db']->getOne(sprintf($sql, "vendor", $row["konzern"]));
            }
            if ($krs) {
                $row["konzernname"] = $krs["name"];
            }
        } else {
            $row["konzernname"] = '';
        }
        if ($tab == "C") {
            $sql = "select count(*) from customer where konzern = " . $id;
        } else {
            $sql = "select count(*) from vendor where konzern = " . $id;
        }
        $knr = $_SESSION['db']->getOne($sql);
        $row["konzernmember"] = $knr["count"];
        if ($tab == "C") {
            $nummer = $row["customernumber"];
        } else {
            $nummer = $row["vendornumber"];
        }
        if ($row["grafik"]) {
            $DIR = $tab . $nummer;
            $image = "./dokumente/" . $_SESSION["dbname"] . "/{$DIR}/logo." . $row["grafik"];
            if (file_exists($image)) {
                $size = @getimagesize($image);
                $row["size"] = $size[3];
                if ($size[1] > $size[0]) {
                    $faktor = ceil($size[1] / 70);
                } else {
                    $faktor = ceil($size[0] / 120);
                }
                $breite = floor($size[0] / $faktor);
                $hoehe = floor($size[1] / $faktor);
                $row["icon"] = "width=\"{$breite}\" height=\"{$hoehe}\"";
            } else {
                $daten["name"] = getcwd() . " {$image}: not found";
            }
        }
        $rs3 = getAllShipto($id, $tab);
        $shipcnt = count($rs3);
        $shipids = array();
        if ($shipcnt > 0) {
            for ($sc = 0; $sc < $shipcnt; $sc++) {
                $shipids[] = "'" . $rs3[$sc]["shipto_id"] . "'";
            }
            $shipids = implode(",", $shipids);
        } else {
            $shipids = "0";
        }
        if (empty($rs3)) {
            // es ist keine abweichende Anschrift da
            if ($ws) {
                // soll dann aber mit Re-Anschrift gefüllt werden
                $row2 = array('shiptoname' => $row["name"], 'shiptodepartment_1' => $row["department_1"], 'shiptodepartment_2' => $row["department_2"], 'shiptostreet' => $row["street"], 'shiptozipcode' => $row["zipcode"], 'shiptocity' => $row["city"], 'shiptocountry' => $row["country"], 'shiptobundesland' => $row["bundesland"], 'shiptocontact' => "", 'shiptophone' => $row["phone"], 'shiptofax' => $row["fax"], 'shiptoemail' => $row["email"], 'shiptocountry' => $row["country"], 'shipto_id' => -1);
            } else {
                // leeres Array bilden
                $row2 = array('shiptoname' => "", 'shiptodepartment_1' => "", 'shiptodepartment_2' => "", 'shiptostreet' => "", 'shiptozipcode' => "", 'shiptocity' => "", 'shiptocountry' => "", 'shiptobundesland' => "", 'shiptocontact' => "", 'shiptophone' => "", 'shiptofax' => "", 'shiptoemail' => "", 'shiptocountrycountry' => "", 'shipto_id' => "");
            }
        } else {
            $row2 = $rs3[0];
        }
        $daten = array_merge($row2, $row);
    }
    //benutzerdef. Variablen:
    if ($cvar) {
        $cvars = getFirmaCVars($id);
        if ($cvars) {
            $daten = array_merge($daten, $cvars);
        }
    }
    $daten["shiptocnt"] = $shipcnt > 0 ? $shipcnt : 0;
    $daten["shiptoids"] = $shipids;
    $daten["op"] = $op;
    $daten["oa"] = $oa;
    $daten["nummer"] = $nummer;
    accessHistory(array($id, $daten['name'], $tab));
    return $daten;
}
예제 #4
0
         $cvheader[] = "vc_cvar_" . $row["name"];
         $header[] = "VC_CVAR_" . strtoupper($row["name"]);
         $cvar++;
     }
 } else {
     $cvar = false;
 }
 insertCSVData($header, -255);
 if ($daten) {
     foreach ($daten as $zeile) {
         $data = array($zeile["greeting"], $zeile["name"], $zeile["department_1"], $zeile["country"], $zeile["zipcode"], $zeile["city"], $zeile["street"], $zeile["phone"], $zeile["fax"], $zeile["email"], $zeile["contact"], $zeile["id"], $Q == "C" ? $zeile["customernumber"] : $zeile["vendornumber"], $zeile["ustid"], $zeile["taxnumber"], $zeile["account_number"], $zeile["bank"], $zeile["bank_code"], $zeile["language_id"], $zeile["business_id"]);
         if (isset($_POST["umsatz"]) and $_POST['umsatz'] != '') {
             $data[] = $zeile["umsatz"];
         }
         if ($cvar > 0) {
             $rs = getFirmaCVars($zeile["id"]);
             if ($rs) {
                 foreach ($cvheader as $cvh) {
                     if (isset($rs[$cvh]) and $rs[$cvh] != '') {
                         $data[] = $rs[$cvh];
                     } else {
                         $data[] = '';
                     }
                 }
             } else {
                 for ($j = 0; $j < $cvar; $j++) {
                     $data[] = false;
                 }
             }
         }
         insertCSVData($data, $zeile["id"]);
예제 #5
0
         $zeile["cp_greeting"] = "Frau";
     }
 } else {
     if ($zeile["cp_gender"] == "m") {
         if ($zeile["language_id"]) {
             $zeile["cp_greeting"] = $anredenHerr[$zeile["language_id"]];
         } else {
             $zeile["cp_greeting"] = "Herr";
         }
     } else {
         $zeile["cp_greeting"] = "KEIN GESCHLECHT";
     }
 }
 $save = array($zeile["cp_greeting"], $zeile["cp_title"], $zeile["cp_name"], $zeile["cp_givenname"], $zeile["cp_country"], $zeile["cp_zipcode"], $zeile["cp_city"], $zeile["cp_street"], $zeile["cp_phone1"], $zeile["cp_fax"], $zeile["cp_email"], $zeile["name"], $zeile["cp_cv_id"], $zeile["cp_gender"], $zeile["cp_id"]);
 if ($cvar > 0) {
     $rs = getFirmaCVars($zeile["cp_cv_id"]);
     if ($rs) {
         foreach ($cvheader as $cvh) {
             $save[] = isset($rs[$cvh]) ? $rs[$cvh] : false;
         }
     } else {
         for ($i = 0; $i < $cvar; $i++) {
             $save[] = false;
         }
     }
 }
 insertCSVData($save, $zeile["cp_id"]);
 if (isset($_POST["FID1"]) && $_POST["FID1"]) {
     $insk = "<input type='checkbox' name='kontid[]' value='" . $zeile["cp_id"] . "'>";
     $js = "";
 } else {