コード例 #1
0
ファイル: client.php プロジェクト: cjbayliss/alloc
function show_client_contacts()
{
    global $TPL;
    global $clientID;
    $TPL["clientContact_clientID"] = $clientID;
    if ($_POST["clientContact_delete"] && $_POST["clientContactID"]) {
        $clientContact = new clientContact();
        $clientContact->set_id($_POST["clientContactID"]);
        $clientContact->delete();
    }
    $client = new client();
    $client->set_id($clientID);
    $client->select();
    // other contacts
    $query = prepare("SELECT * \n                        FROM clientContact\n                       WHERE clientID=%d    \n                    ORDER BY clientContactActive DESC, primaryContact DESC, clientContactName", $clientID);
    $db = new db_alloc();
    $db->query($query);
    while ($db->next_record()) {
        $clientContact = new clientContact();
        $clientContact->read_db_record($db);
        if ($_POST["clientContact_edit"] && $_POST["clientContactID"] == $clientContact->get_id()) {
            continue;
        }
        $pc = "";
        if ($clientContact->get_value("primaryContact")) {
            $pc = " [Primary]";
        }
        $vcard_img = "icon_vcard.png";
        $clientContact->get_value("clientContactActive") or $vcard_img = "icon_vcard_faded.png";
        $vcard = '<a href="' . $TPL["url_alloc_client"] . 'clientContactID=' . $clientContact->get_id() . '&get_vcard=1"><img style="vertical-align:middle; padding:3px 6px 3px 3px;border: none" src="' . $TPL["url_alloc_images"] . $vcard_img . '" alt="Download VCard" ></a>';
        $col1 = array();
        $clientContact->get_value('clientContactName') and $col1[] = "<h2 style='margin:0px; display:inline;'>" . $vcard . $clientContact->get_value('clientContactName', DST_HTML_DISPLAY) . "</h2>" . $pc;
        $clientContact->get_value('clientContactStreetAddress') and $col1[] = $clientContact->get_value('clientContactStreetAddress', DST_HTML_DISPLAY);
        $clientContact->get_value('clientContactSuburb') || $clientContact->get_value('clientContactState') || $clientContact->get_value('clientContactPostcode') and $col1[] = $clientContact->get_value('clientContactSuburb', DST_HTML_DISPLAY) . ' ' . $clientContact->get_value('clientContactState', DST_HTML_DISPLAY) . " " . $clientContact->get_value('clientContactPostcode', DST_HTML_DISPLAY);
        $clientContact->get_value('clientContactCountry') and $col1[] = $clientContact->get_value('clientContactCountry', DST_HTML_DISPLAY);
        // find some gpl icons!
        #$ico_e = "<img src=\"".$TPL["url_alloc_images"]."/icon_email.gif\">";
        #$ico_p = "<img src=\"".$TPL["url_alloc_images"]."/icon_phone.gif\">";
        #$ico_m = "<img src=\"".$TPL["url_alloc_images"]."/icon_mobile.gif\">";
        #$ico_f = "<img src=\"".$TPL["url_alloc_images"]."/icon_fax.gif\">";
        $ico_e = "E: ";
        $ico_p = "P: ";
        $ico_m = "M: ";
        $ico_f = "F: ";
        $col2 = array();
        $email = $clientContact->get_value("clientContactEmail", DST_HTML_DISPLAY);
        $email = str_replace("<", "", $email);
        $email = str_replace(">", "", $email);
        $email = str_replace("&lt;", "", $email);
        $email = str_replace("&gt;", "", $email);
        $userName = $clientContact->get_value('clientContactName', DST_HTML_DISPLAY);
        if ($userName) {
            $mailto = '"' . $userName . '" <' . $email . ">";
        } else {
            $mailto = $email;
        }
        $email and $col2[] = $ico_e . "<a href='mailto:" . rawurlencode($mailto) . "'>" . $email . "</a>";
        $phone = $clientContact->get_value('clientContactPhone', DST_HTML_DISPLAY);
        $phone and $col2[] = $ico_p . $phone;
        $mobile = $clientContact->get_value('clientContactMobile', DST_HTML_DISPLAY);
        $mobile and $col2[] = $ico_m . $mobile;
        $fax = $clientContact->get_value('clientContactFax', DST_HTML_DISPLAY);
        $fax and $col2[] = $ico_f . $fax;
        if ($clientContact->get_value("clientContactActive")) {
            $class_extra = " loud";
        } else {
            $class_extra = " quiet";
        }
        $buttons = '<nobr>
      <button type="submit" name="clientContact_delete" value="1" class="delete_button">Delete<i class="icon-trash"></i></button>
      <button type="submit" name="clientContact_edit" value="1"">Edit<i class="icon-edit"></i></button>
      </nobr>';
        $rtn[] = '<form action="' . $TPL["url_alloc_client"] . '" method="post">';
        $rtn[] = '<input type="hidden" name="clientContactID" value="' . $clientContact->get_id() . '">';
        $rtn[] = '<input type="hidden" name="clientID" value="' . $clientID . '">';
        $rtn[] = '<div class="panel' . $class_extra . ' corner">';
        $rtn[] = '<table width="100%" cellspacing="0" border="0">';
        $rtn[] = '<tr>';
        $rtn[] = '  <td width="25%" valign="top"><span class="nobr">' . implode('</span><br><span class="nobr">', $col1) . '</span>&nbsp;</td>';
        $rtn[] = '  <td width="20%" valign="top"><span class="nobr">' . implode('</span><br><span class="nobr">', $col2) . '</span>&nbsp;</td>';
        $rtn[] = '  <td width="50%" align="left" valign="top">' . nl2br($clientContact->get_value('clientContactOther', DST_HTML_DISPLAY)) . '&nbsp;</td>';
        $rtn[] = '  <td align="right" class="right nobr">' . $buttons . '</td>';
        $rtn[] = '  <td align="right" class="right nobr" width="1%">' . page::star("clientContact", $clientContact->get_id()) . '</td>';
        $rtn[] = '</tr>';
        $rtn[] = '</table>';
        $rtn[] = '</div>';
        $rtn[] = '<input type="hidden" name="sessID" value="' . $TPL["sessID"] . '">';
        $rtn[] = '</form>';
    }
    if (is_array($rtn)) {
        $TPL["clientContacts"] = implode("\n", $rtn);
    }
    if ($_POST["clientContact_edit"] && $_POST["clientContactID"]) {
        $clientContact = new clientContact();
        $clientContact->set_id($_POST["clientContactID"]);
        $clientContact->select();
        $clientContact->set_values("clientContact_");
        if ($clientContact->get_value("primaryContact")) {
            $TPL["primaryContact_checked"] = " checked";
        }
        if ($clientContact->get_value("clientContactActive")) {
            $TPL["clientContactActive_checked"] = " checked";
        }
    } else {
        if ($rtn) {
            $TPL["class_new_client_contact"] = "hidden";
        }
    }
    if (!$_POST["clientContactID"] || $_POST["clientContact_save"]) {
        $TPL["clientContactActive_checked"] = " checked";
    }
    include_template("templates/clientContactM.tpl");
}
コード例 #2
0
ファイル: csv_clients.php プロジェクト: cjbayliss/alloc
        $client->set_value("clientModifiedUser", $current_user->get_id());
        $client->save();
        if ($client->get_id()) {
            if (rtrim($data[9])) {
                $comment = new comment();
                $comment->set_value("commentMaster", "client");
                $comment->set_value("commentMasterID", $client->get_id());
                $comment->set_value("commentType", "client");
                $comment->set_value("commentLinkID", $client->get_id());
                $comment->set_value("comment", $data[9]);
                $comment->save();
                $comment_id = $comment->get_id();
            }
            if ($data[10] || $data[11]) {
                $cc = new clientContact();
                $cc->set_value("clientID", $client->get_id());
                $cc->set_value("primaryContact", 1);
                $cc->set_value("clientContactName", $data[10]);
                $cc->set_value("clientContactEmail", $data[11]);
                $cc->save();
                $cc_id = $cc->get_id();
            }
        }
        $x++;
        echo "<br>" . $client->get_id() . " --- " . $cc_id . " --- " . $comment_id;
        if ($x > 4) {
            //die();
        }
    }
    fclose($handle);
}