function users_list_alm_users_user_photo_BeforeShow(&$sender)
{
    $users_list_alm_users_user_photo_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $users_list;
    //Compatibility
    //End users_list_alm_users_user_photo_BeforeShow
    //Custom Code @31-2A29BDB7
    // -------------------------
    // Write your own code here.
    $db = new clsDBdbConnection();
    $user_guid = $users_list->alm_users->guid->GetValue();
    $photo = trim(CCDLookup("photo", "alm_users", "guid = '{$user_guid}'", $db));
    //Default photo
    if (strlen($photo) <= 0) {
        $photo = "user128.png";
    }
    $options = Options::getConsoleOptions();
    $url = $options["console_internal_url"] . $options["console_users_url"] . $photo;
    $users_list->alm_users->user_photo->SetValue($url);
    $db->close();
    // -------------------------
    //End Custom Code
    //Close users_list_alm_users_user_photo_BeforeShow @30-EE399A43
    return $users_list_alm_users_user_photo_BeforeShow;
}
function products_maintcontent_alm_products_suite_code_BeforeShow(&$sender)
{
    $products_maintcontent_alm_products_suite_code_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $products_maintcontent;
    //Compatibility
    //End products_maintcontent_alm_products_suite_code_BeforeShow
    //Custom Code @39-2A29BDB7
    // -------------------------
    // Write your own code here.
    $suite_id = $sender->GetValue();
    $db = new clsDBdbConnection();
    $suite_description = CCDLookup("suite_description", "alm_product_suites", "id = {$suite_id}", $db);
    $products_maintcontent->alm_products->description->SetValue($suite_description);
    $db->close();
    // -------------------------
    //End Custom Code
    //Close products_maintcontent_alm_products_suite_code_BeforeShow @7-CEF8E22D
    return $products_maintcontent_alm_products_suite_code_BeforeShow;
}
function licensing_customerscontent_licensing_BeforeInsert(&$sender)
{
    $licensing_customerscontent_licensing_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_customerscontent;
    //Compatibility
    //End licensing_customerscontent_licensing_BeforeInsert
    //Custom Code @188-2A29BDB7
    // -------------------------
    // Write your own code here.
    $suiteId = $licensing_customerscontent->licensing->suite_code->GetValue();
    $params = array();
    $params["suite_id"] = $suiteId;
    $products = new Alm\Products();
    $suiteStatus = $products->getSuiteStatusById($params);
    //Check if suite status is active or legacy before adding any new licenses to a customer
    if ($suiteStatus["suiteStatus"] == "1" || $suiteStatus["suiteStatus"] == "2") {
        $guid = uuid_create();
        global $lastguid;
        $lastguid = $guid;
        $licensing_customerscontent->licensing->created_iduser->SetValue(CCGetUserID());
        $licensing_customerscontent->licensing->hidguid->SetValue($guid);
        //Customer ID for the license
        $customer_guid = trim($licensing_customerscontent->licensing->hidcustomer_guid->GetValue());
        $db = new clsDBdbConnection();
        $customer_id = CCDLookup("id", "alm_customers", "guid = '{$customer_guid}'", $db);
        $db->close();
        $licensing_customerscontent->licensing->hidcustomer_id->SetValue($customer_id);
        //Changing license status to active when inactive and grant,expdate,expirdate are present
        $grantNo = trim($licensing_customerscontent->licensing->grant_number->GetValue());
        $expDate = $licensing_customerscontent->licensing->expedition_date->GetValue();
        $expirDate = $licensing_customerscontent->licensing->expiration_date->GetValue();
        $licenseStatus = (int) $licensing_customerscontent->licensing->hidlicensestatus->GetValue();
        $licenseType = (int) $licensing_customerscontent->licensing->id_license_type->GetValue();
        $o = trim($licensing_customerscontent->licensing->hido->GetValue());
        $dguid = trim($licensing_customerscontent->licensing->hiddguid->GetValue());
        $params = array();
        $params["guid"] = $dguid;
        if ($o == "renew") {
            //Keeps the expired license guid reference on the new renewed license
            $licensing_customerscontent->licensing->hidexpired_license_guid->SetValue($dguid);
        }
        //Making sure that perpetual licenses dont get expiration date values
        //And change status to active if grantnumber, expiration date have values
        //This changed, perpetuals will be autoactivated and user redirected to add the support license automatically
        if ($licenseStatus == 1 && strlen($grantNo) > 0 && count($expDate) > 1 && count($expirDate) > 1) {
            if ($licenseType == 7 || $licenseType == 12) {
                $licensing_customerscontent->licensing->expiration_date->SetValue("");
            }
            $licensing_customerscontent->licensing->hidlicensestatus->SetValue("2");
            //If renewing and new license is activated, sets expired license as archived
            if ($o == "renew") {
                $products = new Alm\Products();
                $products->setLicenseArchivedByGuid($params);
            }
        } else {
            //Its a perpetual license
            if ($licenseStatus == 1 && ($licenseType == 7 || $licenseType == 12)) {
                $licensing_customerscontent->licensing->expiration_date->SetValue("");
                $licensing_customerscontent->licensing->hidlicensestatus->SetValue("2");
            }
        }
        //Checking if its an addsupport operation to set the support parent perpetual license
        $parentLicenseGuid = trim($licensing_customerscontent->licensing->hiddguid->GetValue());
        $o = trim($licensing_customerscontent->licensing->hido->GetValue());
        if ($o == "addsupport" && strlen($parentLicenseGuid) > 0) {
            $licensing_customerscontent->licensing->hidparent_license_guid->SetValue($parentLicenseGuid);
        }
        //Upgrade licensing
        $o = $licensing_customerscontent->licensing->hido->GetValue();
        if (strlen($dguid) > 0 && $o == "upgrade_license") {
            //Keeps the expired license guid reference on the new renewed license
            $licensing_customerscontent->licensing->hidexpired_license_guid->SetValue($dguid);
            $params = array();
            $params["guid"] = $dguid;
            $products = new Alm\Products();
            $products->setLicenseArchivedByGuid($params);
        }
    } else {
        global $CCSLocales;
        $licensing_customerscontent->licensing->InsertAllowed = false;
        $licensing_customerscontent->licensing->Errors->clear();
        $licensing_customerscontent->licensing->Errors->addError($CCSLocales->GetText("suite_status_notactivelegacy"));
    }
    // -------------------------
    //End Custom Code
    //Close licensing_customerscontent_licensing_BeforeInsert @154-8C89F39C
    return $licensing_customerscontent_licensing_BeforeInsert;
}
Ejemplo n.º 4
0
 public function saveContactSubHobbies($params = array())
 {
     $result = array("status" => false, "message" => "", "result" => array());
     $subhobbie = $params["subhobbie"];
     $contact_guid = $params["contact_guid"];
     $parent_id = $params["parent_id"];
     if (strlen($contact_guid) > 0) {
         $db2 = new clsDBdbConnection();
         $subhobbies_list = "";
         foreach ($subhobbie as $hobbie) {
             $subhobbies_list .= $hobbie . ",";
         }
         //Check if subhobbies for the parent_id has been added for the contact
         $contact_id = CCDLookup("id", "alm_customers_contacts", "guid = '{$contact_guid}'", $db2);
         $parent_hobbie = (int) CCDLookup("1 as exist", "alm_customers_contacts_subhobbies_details", "contact_id = {$contact_id} and hobbie_id = {$parent_id}", $db2);
         $contact_hobbies = CCDLookup("hobbies", "alm_customers_contacts", "id = {$contact_id}", $db2);
         $contact_hobbies = trim($contact_hobbies, ",");
         $contact_hobbies = explode(",", $contact_hobbies);
         if (!in_array($parent_id, $contact_hobbies)) {
             $contact_hobbies[] = $parent_id;
         }
         $contact_hobbies = implode(",", $contact_hobbies);
         $sql2 = "update alm_customers_contacts set hobbies = '{$contact_hobbies}' where id = {$contact_id} ";
         $db2->query($sql2);
         if ($parent_hobbie == 1) {
             $sql2 = "update alm_customers_contacts_subhobbies_details set subhobbies = '{$subhobbies_list}' where contact_id = {$contact_id} and hobbie_id = {$parent_id}";
             $db2->query($sql2);
         } else {
             $guidDetail = uuid_create();
             $sql2 = "insert into alm_customers_contacts_subhobbies_details(guid,contact_id, hobbie_id, subhobbies) values('{$guidDetail}',{$contact_id}, {$parent_id}, '{$subhobbies_list}')";
             $db2->query($sql2);
         }
         $db2->close();
         $result["status"] = true;
         $result["message"] = "Command executed successfully";
         return $result;
     }
     return $result;
 }
function contacts_holidays_maintcontent_alm_contacts_holidays_pnday_position_BeforeShow(&$sender)
{
    $contacts_holidays_maintcontent_alm_contacts_holidays_pnday_position_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $contacts_holidays_maintcontent;
    //Compatibility
    //End contacts_holidays_maintcontent_alm_contacts_holidays_pnday_position_BeforeShow
    //Custom Code @25-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = CCGetFromGet("guid", "");
    if (strlen($guid) > 0) {
        $db = new clsDbdbConnection();
        $holiday_id = (int) CCDLookup("id", "alm_customers_contacts_holidays", "guid = '{$guid}'", $db);
        if ($holiday_id == 2 || $holiday_id == 3) {
            $contacts_holidays_maintcontent->alm_contacts_holidays->pnday_position->Visible = true;
        } else {
            $contacts_holidays_maintcontent->alm_contacts_holidays->pnday_position->Visible = false;
        }
        $db->close();
    } else {
        $contacts_holidays_maintcontent->alm_contacts_holidays->pnday_position->Visible = false;
    }
    // -------------------------
    //End Custom Code
    //Close contacts_holidays_maintcontent_alm_contacts_holidays_pnday_position_BeforeShow @24-21C15399
    return $contacts_holidays_maintcontent_alm_contacts_holidays_pnday_position_BeforeShow;
}
function contacts_maintcontent_alm_customers_contacts_BeforeShow(&$sender)
{
    $contacts_maintcontent_alm_customers_contacts_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $contacts_maintcontent;
    //Compatibility
    //End contacts_maintcontent_alm_customers_contacts_BeforeShow
    //Custom Code @37-2A29BDB7
    // -------------------------
    // Write your own code here.
    global $Tpl;
    $guid = CCGetFromGet("guid", "");
    $db = new clsDBdbConnection();
    $db2 = new clsDBdbConnection();
    $db3 = new clsDBdbConnection();
    $contact_hobbies = explode(",", trim($contacts_maintcontent->alm_customers_contacts->hidhobbies->GetValue(), ","));
    $sql = "select id,hobbies from alm_customers_contacts_hobbies";
    $db->query($sql);
    while ($db->next_record()) {
        $hobbie_id = $db->f("id");
        $Tpl->setvar("hobbie_value", $hobbie_id);
        $Tpl->setvar("hobbie_title", $db->f("hobbies"));
        if (in_array($db->f("id"), $contact_hobbies)) {
            $Tpl->setvar("hobbie_checked", "checked");
        } else {
            $Tpl->setvar("hobbie_checked", "");
        }
        $parentPath = $Tpl->block_path;
        $Tpl->block_path = $Tpl->block_path . "/hobbies_list";
        $Tpl->SetBlockVar("subhobbies_list", "");
        $sql2 = "select id,subhobbi from alm_customers_contacts_subhobbies where hobbie_id = {$hobbie_id}";
        $db2->query($sql2);
        $contact_guid = $contacts_maintcontent->alm_customers_contacts->hidguid->GetValue();
        $contact_id = CCDLookup("id", "alm_customers_contacts", "guid = '{$contact_guid}'", $db3);
        $subhobbie = CCDLookup("subhobbies", "alm_customers_contacts_subhobbies_details", "contact_id = {$contact_id} and hobbie_id = {$hobbie_id}", $db3);
        $subhobbie = explode(",", $subhobbie);
        while ($db2->next_record()) {
            $subhubbie_id = $db2->f("id");
            if (in_array($subhubbie_id, $subhobbie)) {
                $Tpl->setvar("subhobbie_checked", "checked");
            } else {
                $Tpl->setvar("subhobbie_checked", "");
            }
            $Tpl->setvar("parent_hobbie", $hobbie_id);
            $Tpl->setvar("subhobbie_value", $subhubbie_id);
            $Tpl->setvar("subhobbie_title", $db2->f("subhobbi"));
            $Tpl->Parse("subhobbies_list", true);
        }
        $table_detail = $Tpl->GetVar("subhobbies_list");
        $Tpl->block_path = $parentPath;
        $Tpl->SetBlockVar("subhobbies_list", $table_detail);
        $Tpl->Parse("hobbies_list", true);
    }
    $db3->close();
    $db2->close();
    $db->close();
    // -------------------------
    //End Custom Code
    //Close contacts_maintcontent_alm_customers_contacts_BeforeShow @2-DACA5085
    return $contacts_maintcontent_alm_customers_contacts_BeforeShow;
}
function customers_maintcontent_alm_customers_BeforeShow(&$sender)
{
    $customers_maintcontent_alm_customers_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $customers_maintcontent;
    //Compatibility
    //End customers_maintcontent_alm_customers_BeforeShow
    //Custom Code @140-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = CCGetFromGet("guid", "");
    $contact_guid = CCGetFromGet("contact_guid", "");
    $tab = CCGetFromGet("tab", "");
    $o = CCGetFromGet("o", "");
    $params = array();
    $params["customer_guid"] = $guid;
    $params["contact_guid"] = $contact_guid;
    if (strlen($guid) > 0) {
        global $Tpl;
        global $FileName;
        $customers = new Customers();
        $contacts = $customers->getCustomerContacts($params);
        $contacts = $contacts["contacts"];
        $querystring = CCGetQueryString("QueryString", array("contact_guid"));
        $db = new clsDBdbConnection();
        foreach ($contacts as $contact) {
            $editurl = $FileName . "?{$querystring}&contact_guid=" . $contact["guid"] . "&tab=addcontact";
            $Tpl->setvar("lbedit", $editurl);
            if ($contact["maincontact"] == "1") {
                $Tpl->setvar("lbmaincontact", "");
            } else {
                $Tpl->setvar("lbmaincontact", "hide");
            }
            $Tpl->setvar("lbcontact", $contact["contact"]);
            $jobposition = $contact["jobposition"];
            $jobposition = CCDLookup("jobposition", "alm_jobpositions", "id = {$jobposition}", $db);
            $Tpl->setvar("lbcontact_jobposition", $jobposition);
            $Tpl->setvar("lbcontact_phone", $contact["phone"]);
            $Tpl->setvar("lbcontact_extension", $contact["extension"]);
            $Tpl->setvar("lbcontact_mobile", $contact["mobile"]);
            $Tpl->setvar("lbcontact_workemail", $contact["workemail"]);
            $Tpl->setvar("lbcontact_personalemail", $contact["personalemail"]);
            $dateupdated = $contact["dateupdated"];
            if (strlen($dateupdated) > 0) {
                $dateupdated_array = CCParseDate($dateupdated, array("yyyy", "-", "mm", "-", "dd", " ", "H", ":", "n", ":", "s"));
                $format = array("mm", "/", "dd", "/", "yyyy", " ", "hh", ":", "nn", " ", "AM/PM");
                $dateupdated = CCFormatDate($dateupdated_array, $format);
                $Tpl->setvar("lbcontact_dateupdated", $dateupdated);
            }
            $Tpl->parse("contact_list", true);
        }
        $db->close();
    }
    //Filling up contact info for updates
    if (strlen($contact_guid) > 0 && $o != "delcontact") {
        $customers = new Customers();
        $contacts = $customers->getCustomerContactByGuid($params);
        $contacts = $contacts["contacts"];
        if (is_array($contacts[0])) {
            $customers_maintcontent->alm_customers->contact->SetValue($contacts[0]["contact"]);
            $customers_maintcontent->alm_customers->contact_jobposition->SetValue($contacts[0]["jobposition"]);
            $customers_maintcontent->alm_customers->contact_phone->SetValue($contacts[0]["phone"]);
            $customers_maintcontent->alm_customers->contact_extension->SetValue($contacts[0]["extension"]);
            $customers_maintcontent->alm_customers->contact_mobile->SetValue($contacts[0]["mobile"]);
            $customers_maintcontent->alm_customers->contact_workemail->SetValue($contacts[0]["workemail"]);
            $customers_maintcontent->alm_customers->contact_personalemail->SetValue($contacts[0]["personalemail"]);
            $customers_maintcontent->alm_customers->contact_maincontact->SetValue($contacts[0]["maincontact"]);
            $contact_dob = $contacts[0]["contact_dob"];
            $contact_dob_array = CCParseDate($contact_dob, array("yyyy", "-", "mm", "-", "dd"));
            if ($contact_dob_array[1] == "0000") {
                $contact_dob_array = null;
            }
            $customers_maintcontent->alm_customers->contact_dob->SetValue($contact_dob_array);
            $contact_preferred_color = explode(",", $contacts[0]["preferred_color"]);
            $customers_maintcontent->alm_customers->contact_preferred_color->Multiple = true;
            $customers_maintcontent->alm_customers->contact_preferred_color->SetValue($contact_preferred_color);
            $contact_hobbies = explode(",", $contacts[0]["hobbies"]);
            $customers_maintcontent->alm_customers->contact_hobbies->Multiple = true;
            $customers_maintcontent->alm_customers->contact_hobbies->SetValue($contact_hobbies);
            $contact_holidays = explode(",", $contacts[0]["notify_holidays"]);
            $customers_maintcontent->alm_customers->contact_notify_holidays->Multiple = true;
            $customers_maintcontent->alm_customers->contact_notify_holidays->SetValue($contact_holidays);
        }
    }
    // -------------------------
    //End Custom Code
    //Close customers_maintcontent_alm_customers_BeforeShow @8-32D525B2
    return $customers_maintcontent_alm_customers_BeforeShow;
}
function customers_viewcontent_alm_customers_BeforeShow(&$sender)
{
    $customers_viewcontent_alm_customers_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $customers_viewcontent;
    //Compatibility
    //End customers_viewcontent_alm_customers_BeforeShow
    //Custom Code @157-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = CCGetFromGet("guid", "");
    $contact_guid = CCGetFromGet("contact_guid", "");
    $tab = CCGetFromGet("tab", "");
    $o = CCGetFromGet("o", "");
    $params = array();
    $params["customer_guid"] = $guid;
    $params["contact_guid"] = $contact_guid;
    if (strlen($guid) > 0) {
        global $Tpl;
        global $FileName;
        $customers = new Customers();
        $contacts = $customers->getCustomerContacts($params);
        $contacts = $contacts["contacts"];
        $querystring = CCGetQueryString("QueryString", array());
        $db = new clsDBdbConnection();
        foreach ($contacts as $contact) {
            //$editurl = $FileName."?$querystring&contact_guid=".$contact["guid"]."&tab=addcontact";
            //$deleteurl = $FileName."?$querystring&contact_guid=".$contact["guid"]."&tab=addcontact&o=delcontact";
            //$Tpl->setvar("lbedit","");
            //$Tpl->setvar("lbdelete","");
            $Tpl->setvar("lbcontact", $contact["contact"]);
            if ($contact["maincontact"] == "1") {
                $Tpl->setvar("lbmaincontact", "");
            } else {
                $Tpl->setvar("lbmaincontact", "hide");
            }
            $jobposition = $contact["jobposition"];
            $jobposition = CCDLookup("jobposition", "alm_jobpositions", "id = {$jobposition}", $db);
            $Tpl->setvar("lbcontact_jobposition", $jobposition);
            $Tpl->setvar("lbcontact_phone", $contact["phone"]);
            $Tpl->setvar("lbcontact_extension", $contact["extension"]);
            $Tpl->setvar("lbcontact_mobile", $contact["mobile"]);
            $Tpl->setvar("lbcontact_workemail", $contact["workemail"]);
            $Tpl->setvar("lbcontact_personalemail", $contact["personalemail"]);
            $dateupdated = $contact["dateupdated"];
            if (strlen($dateupdated) > 0) {
                $dateupdated_array = CCParseDate($dateupdated, array("yyyy", "-", "mm", "-", "dd", " ", "H", ":", "n", ":", "s"));
                $format = array("mm", "/", "dd", "/", "yyyy", " ", "hh", ":", "nn", " ", "AM/PM");
                $dateupdated = CCFormatDate($dateupdated_array, $format);
                $Tpl->setvar("lbcontact_dateupdated", $dateupdated);
            }
            $Tpl->parse("contact_list", true);
        }
        $db->close();
    }
    // -------------------------
    //End Custom Code
    //Close customers_viewcontent_alm_customers_BeforeShow @2-99C5ED0C
    return $customers_viewcontent_alm_customers_BeforeShow;
}