function licensing_customerscontent_alm_customers_BeforeShow(&$sender) { $licensing_customerscontent_alm_customers_BeforeShow = true; $Component =& $sender; $Container =& CCGetParentContainer($sender); global $licensing_customerscontent; //Compatibility //End licensing_customerscontent_alm_customers_BeforeShow //Custom Code @150-2A29BDB7 // ------------------------- // Write your own code here. $guid = CCGetFromGet("guid", ""); $license_guid = CCGetFromGet("license_guid", ""); $tab = CCGetFromGet("tab", ""); $o = CCGetFromGet("o", ""); $params = array(); $params["customer_guid"] = $guid; $params["license_guid"] = $license_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 licensing_customerscontent_alm_customers_BeforeShow @2-4616A461 return $licensing_customerscontent_alm_customers_BeforeShow; }
function CCDateAdd($date, $value) { if (CCValidateDate($date)) { $FormatArray = array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss"); $value = strtolower($value); preg_match_all("/([-+]?)(\\d+)\\s*(year(s?)|month(s?)|day(s?)|hour(s?)|minute(s?)|second(s?)|week(s?)|[ymdwhns])/", $value, $pieces); for ($i = 0; $i < count($pieces[0]); $i++) { $rel = $pieces[1][$i] == "-" ? -$pieces[2][$i] : $pieces[2][$i]; $BackMonth = false; switch ($pieces[3][$i]) { case "years": case "year": case "y": $date[ccsYear] += $rel; $BackMonth = true; break; case "months": case "month": case "m": $date[ccsMonth] += $rel; $BackMonth = true; break; case "weeks": case "week": case "w": $date[ccsDay] += $rel * 7; break; case "days": case "day": case "d": $date[ccsDay] += $rel; break; case "hours": case "hour": case "h": $date[ccsHour] += $rel; break; case "minutes": case "minute": case "min": case "n": $date[ccsMinute] += $rel; break; case "seconds": case "second": case "sec": case "s": $date[ccsSecond] += $rel; break; } if ($date[ccsSecond] >= 60) { $date[ccsMinute] += floor($date[ccsSecond] / 60); $date[ccsSecond] = $date[ccsSecond] % 60; } elseif ($date[ccsSecond] < 0) { $date[ccsMinute] += floor($date[ccsSecond] / 60); $date[ccsSecond] = ($date[ccsSecond] % 60 + 60) % 60; } if ($date[ccsMinute] >= 60) { $date[ccsHour] += floor($date[ccsMinute] / 60); $date[ccsMinute] = $date[ccsMinute] % 60; } elseif ($date[ccsMinute] < 0) { $date[ccsHour] += floor($date[ccsMinute] / 60); $date[ccsMinute] = ($date[ccsMinute] % 60 + 60) % 60; } if ($date[ccsHour] >= 24) { $date[ccsDay] += floor($date[ccsHour] / 24); $date[ccsHour] = $date[ccsHour] % 24; } elseif ($date[ccsHour] < 0) { $date[ccsDay] += floor($date[ccsHour] / 24); $date[ccsHour] = ($date[ccsHour] % 24 + 24) % 24; } if ($date[ccsMonth] > 12) { $date[ccsYear] += floor(($date[ccsMonth] - 1) / 12); $date[ccsMonth] = ($date[ccsMonth] - 1) % 12 + 1; } elseif ($date[ccsMonth] < 1) { $date[ccsYear] += floor(($date[ccsMonth] - 1) / 12); $date[ccsMonth] = (($date[ccsMonth] - 1) % 12 + 12) % 12 + 1; } $days = CCDaysInMonth($date[ccsYear], $date[ccsMonth]); if ($BackMonth && $date[ccsDay] > $days) { $date[ccsDay] = $days; } else { while ($date[ccsDay] > $days) { $date[ccsMonth] += 1; if ($date[ccsMonth] > 12) { $date[ccsYear] += 1; $date[ccsMonth] = 1; } $date[ccsDay] = $date[ccsDay] - $days; $days = CCDaysInMonth($date[ccsYear], $date[ccsMonth]); } } if ($BackMonth && $date[ccsDay] < 1) { $date[ccsDay] = 1; } else { $tmpDate = ""; while ($date[ccsDay] < 1) { if ($tmpDate == "") { $tmpDate = CCParseDate(CCFormatDate($date, array("yyyy", "-", "mm", "-01")), array("yyyy", "-", "mm", "-", "dd")); } $tmpDate = CCDateAdd($tmpDate, "-1month"); $days = CCDaysInMonth($tmpDate[ccsYear], $tmpDate[ccsMonth]); $date[ccsMonth] -= 1; if ($date[ccsMonth] == 0) { $date[ccsYear] -= 1; $date[ccsMonth] = 12; } $date[ccsDay] = $date[ccsDay] + $days; } } } $date[ccsTimestamp] = @mktime($date[ccsHour], $date[ccsMinute], $date[ccsSecond], $date[ccsMonth], $date[ccsDay], $date[ccsYear]); return $date; } return false; }
function GetFormatedValue() { $strResult = ""; switch ($this->DataType) { case ccsDate: $strResult = CCFormatDate($this->Value, $this->DBFormat); break; case ccsBoolean: $strResult = CCFormatBoolean($this->Value, $this->DBFormat); break; case ccsInteger: case ccsFloat: $strResult = CCFormatNumber($this->Value, $this->DBFormat); break; case ccsText: case ccsMemo: $strResult = strval($this->Value); break; } return $strResult; }
function Show() { global $CCSUseAmp; global $Tpl; global $FileName; $this->EventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this); if (!$this->Visible) { return; } $RemoveFromUrl = array($this->TargetName . "Year", $this->TargetName . "Month", $this->TargetName . "Date"); $QueryString = CCGetQueryString("QueryString", $RemoveFromUrl); $ParentPath = $Tpl->block_path; $CalendarNavigatorBlock = "CalendarNavigator " . $this->CalendarNavigatorName; $Tpl->block_path = $ParentPath . "/" . $CalendarNavigatorBlock; $Tpl->SetBlockVar("", ""); $Tpl->SetBlockVar("Years", ""); $Tpl->SetBlockVar("Months", ""); $Tpl->SetBlockVar("Quarters", ""); $this->Attributes->Show(); $Blocks = array("Months", "Quarters", "Years"); foreach ($Blocks as $Block) { if ($Tpl->BlockExists($Block)) { if ($Block == "Years") { $this->CurrentProcessingDate = CCDateAdd($this->CurrentDate, "-" . $this->YearsRange . "years"); $LastDate = CCDateAdd($this->CurrentDate, "+" . $this->YearsRange . "years"); $add = "1year"; $name = "Year"; } elseif ($Block == "Quarters" && $this->CalendarType == "Quarter") { $this->CurrentProcessingDate = CCParseDate(CCFormatDate($this->CurrentDate, array("yyyy", "-01-01 00:00:00")), array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss")); $LastDate = CCDateAdd($this->CurrentProcessingDate, "+1year -1sec"); $add = "3month"; $name = "Quarter"; } elseif ($this->CalendarType != 12) { $this->CurrentProcessingDate = CCParseDate(CCFormatDate($this->CurrentDate, array("yyyy", "-01-01 00:00:00")), array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss")); $LastDate = CCDateAdd($this->CurrentProcessingDate, "+1year -1sec"); $add = "1month"; $name = "Month"; } else { continue; } while (CCCompareValues($this->CurrentProcessingDate, $LastDate, ccsDate) <= 0) { $NextDate = CCDateAdd($this->CurrentProcessingDate, $add); if ($Block == "Years" && $this->CurrentProcessingDate[ccsYear] == $this->CurrentDate[ccsYear] || $Block == "Months" && $this->CurrentProcessingDate[ccsMonth] == $this->CurrentDate[ccsMonth] || $Block == "Quarters" && ceil($this->CurrentProcessingDate[ccsMonth] / 3 + 0.1) == ceil($this->CurrentDate[ccsMonth] / 3)) { $this->ShowBlock($QueryString, $Block . "/Current_" . $name, $Block . "/Regular_" . $name); } else { $this->ShowBlock($QueryString, $Block . "/Regular_" . $name); } $this->CurrentProcessingDate = $NextDate; } $this->ShowBlock($QueryString, $Block); } } if ($Tpl->BlockExists("Prev_Year")) { $this->CurrentProcessingDate = CCDateAdd($this->CurrentDate, "-1year"); $this->ShowBlock($QueryString, "Prev_Year", "", false); } if ($Tpl->BlockExists("Next_Year")) { $this->CurrentProcessingDate = CCDateAdd($this->CurrentDate, "+1year"); $this->ShowBlock($QueryString, "Next_Year", "", false); } if ($this->CalendarType != 12) { if ($Tpl->BlockExists("Prev")) { $this->CurrentProcessingDate = $this->PrevProcessingDate; $this->ShowBlock($QueryString, "Prev", "", false); } if ($Tpl->BlockExists("Next")) { $this->CurrentProcessingDate = $this->NextProcessingDate; $this->ShowBlock($QueryString, "Next", "", false); } } $Tpl->block_path = $ParentPath; $ActionStr = $FileName . "?" . CCAddParam($QueryString, "ccsForm", $this->TargetName); if ($CCSUseAmp) { $ActionStr = str_replace('&', '&', $ActionStr); } $Tpl->SetVar("Action", $ActionStr); $Tpl->SetVar("CalendarName", $this->TargetName); $this->CurrentProcessingDate = $this->CurrentDate; $this->ShowBlock($QueryString, $CalendarNavigatorBlock, "", false); }
function SQLValue($Value, $ValueType) { if ($ValueType == ccsDate && is_array($Value)) { $Value = CCFormatDate($Value, $this->DateFormat); } if (is_array($Value)) { $Value = count($Value) ? $Value[0] : ""; } if (!strlen($Value)) { return ""; } else { if ($ValueType == ccsInteger || $ValueType == ccsFloat) { return doubleval(str_replace(",", ".", $Value)); } else { if ($ValueType == ccsBoolean) { if (is_bool($Value)) { $Value = CCFormatBoolean($Value, $this->BooleanFormat); } else { if (is_numeric($Value)) { $Value = intval($Value); } else { if (strtoupper($Value) == "TRUE" || strtoupper($Value) == "FALSE") { $Value = strtoupper($Value); } else { $Value = $this->esc($Value); } } } return $Value; } else { return $this->esc($Value); } } } }
function CalculateCalendarPeriod() { $this->FirstProcessingDate = CCParseDate(CCFormatDate($this->CurrentDate, array("yyyy", "-", "mm", "-01 00:00:00")), array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss")); $Days = (CCFormatDate($this->FirstProcessingDate, array("w")) - $this->FirstWeekDay + 6) % 7; $this->StartDate = CCDateAdd($this->FirstProcessingDate, "-" . $Days . "day"); $this->LastProcessingDate = CCDateAdd($this->FirstProcessingDate, "1month -1second"); $Days = ($this->FirstWeekDay - CCFormatDate($this->LastProcessingDate, array("w")) + 7) % 7; $this->EndDate = CCDateAdd($this->LastProcessingDate, $Days . "day"); }
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 licensing_bulkrenewalcontent_BeforeShow(&$sender) { $licensing_bulkrenewalcontent_BeforeShow = true; $Component =& $sender; $Container =& CCGetParentContainer($sender); global $licensing_bulkrenewalcontent; //Compatibility //End licensing_bulkrenewalcontent_BeforeShow //Custom Code @2-2A29BDB7 // ------------------------- // Write your own code here. //*******************************// //Licensing active // //*******************************// $guid = CCGetFromGet("guid", ""); $grantNumber = CCGetFromGet("grant_number", ""); $tab = CCGetFromGet("tab", ""); $o = CCGetFromGet("o", ""); $params = array(); $params["grant_number"] = $grantNumber; //Settingup saved message popup global $MainPage; global $Tpl; global $FileName; $showalert = CCGetSession("showalert", "hide"); $MainPage->Attributes->SetValue("showalert", $showalert); if ($showalert == "show") { CCSetSession("showalert", "hide"); } $showerror = CCGetSession("showerror", "hide"); $MainPage->Attributes->SetValue("showerror", $showerror); if ($showerror == "show") { CCSetSession("showerror", "hide"); } $o_post = CCGetFromPost("hido", ""); $grant_post = CCGetFromPost("hidgrant_number", ""); $newgrant_post = CCGetFromPost("grantnumber", ""); $tab_post = CCGetFromPost("hidtab", "licenselist"); $guid_post = CCGetFromPost("hidguid", ""); $exped_post = CCGetFromPost("expedition_date", ""); $expir_post = CCGetFromPost("expiration_date", ""); if ($o_post == "bulkrenewal") { if (strlen($grant_post) > 0 && strlen($newgrant_post) > 0 && strlen($exped_post) > 0 && strlen($expir_post) > 0) { //Reformating the dates $exped_array = CCParseDate($exped_post, array("mm", "/", "dd", "/", "yyyy")); $format = array("yyyy", "-", "mm", "-", "dd"); $exped_post = CCFormatDate($exped_array, $format); //Reformating the dates $expir_array = CCParseDate($expir_post, array("mm", "/", "dd", "/", "yyyy")); $format = array("yyyy", "-", "mm", "-", "dd"); $expir_post = CCFormatDate($expir_array, $format); $params["newgrant_number"] = $newgrant_post; $params["grant_number"] = $grant_post; $params["expedition_date"] = $exped_post; $params["expiration_date"] = $expir_post; $params["user_id"] = CCGetUserID(); $products = new \Alm\Products(); $result = $products->bulkRenew($params); if ($result["status"]) { CCSetSession("showalert", "show"); header("Location: licensing_customers.php?guid={$guid_post}&tab={$tab_post}"); } else { CCSetSession("showerror", "show"); header("Location: {$FileName}?guid={$guid_post}&o={$o_post}&grant_number={$grant_post}&tab={$tab_post}"); } } else { CCSetSession("showerror", "show"); header("Location: {$FileName}?guid={$guid_post}&o={$o_post}&grant_number={$grant_post}&tab={$tab_post}"); } } //endif o_post if (strlen($grantNumber) > 0 && $o == "bulkrenewal") { global $Tpl; global $FileName; //Filling up licenses grid $products = new \Alm\Products(); $licenses = $products->getLicensesByGrantNumber($params); $allLicenses = $licenses["licenses"]; foreach ($allLicenses as $license) { $Tpl->setvar("lbguid", $guid); $Tpl->setvar("lblicense_guid", $license["guid"]); $Tpl->setvar("lbsuite_code", $license["suite_code"]); $Tpl->setvar("lbsuite_description", $license["suite_description"]); $Tpl->setvar("lbdescription", $license["description"]); $Tpl->setvar("lbproduct_typeicon", $license["type_icon_name"]); $Tpl->setvar("lblicense_name", $license["license_name"]); $Tpl->setvar("lblicensedby_name", $license["licensedby_name"]); $Tpl->setvar("lblicense_status", $license["license_status_name"]); $Tpl->setvar("lblicense_status_css", $license["alm_license_status_css_color"]); if ($license["id_licensed_by"] == "1") { $Tpl->setvar("lbnodes_qty", $license["nodes"]); } else { $Tpl->setvar("lbnodes_qty", $license["licensed_amount"]); } //Total cost of license $price = $license["msrp_price"]; $licenseBy = $license["id_licensed_by"]; $nodes = $license["nodes"]; $licenseAmount = $license["licensed_amount"]; //Hides the granttype info if not value present if (strlen(trim($license["grant_number"])) <= 0) { $Tpl->setvar("lbgranttype_class", "hide"); } else { $Tpl->setvar("lbgranttype_class", ""); $Tpl->setvar("lbgranttype", $license["granttype_name"]); $Tpl->setvar("lbgrantnumber", $license["grant_number"]); } if (strlen(trim($license["serial_number"])) <= 0) { $Tpl->setvar("lbserial_class", "hide"); } else { $Tpl->setvar("lbserial_class", ""); $Tpl->setvar("lbserialnumber", $license["serial_number"]); } $Tpl->setvar("lblicense_for", $license["sector_name"]); if (strlen($license["expedition_date"]) <= 0) { $expDate = ""; } else { $expDate = date("m/d/Y", strtotime($license["expedition_date"])); } $Tpl->setvar("lbexpedition", $expDate); if (strlen($license["expiration_date"]) <= 0) { $expirDate = ""; } else { $expirDate = date("m/d/Y", strtotime($license["expiration_date"])); } $Tpl->setvar("lbexpiration", $expirDate); $Tpl->parse("license_list", true); } } // Licensing active // ------------------------- //End Custom Code //Close licensing_bulkrenewalcontent_BeforeShow @1-AC2FBD05 return $licensing_bulkrenewalcontent_BeforeShow; }