Ejemplo n.º 1
0
 /**
  * Creates a new Tenant object based on the given values from the database.
  * @param array $values
  * @return \PhoenixSNS\Objects\Tenant based on the values of the fields in the given associative array
  */
 public static function GetByAssoc($values)
 {
     $item = new Tenant();
     $item->ID = $values["tenant_ID"];
     $item->URL = $values["tenant_URL"];
     $item->Description = $values["tenant_Description"];
     switch ($values["tenant_Status"]) {
         case 1:
             $item->Status = TenantStatus::Enabled;
             break;
         case 0:
             $item->Status = TenantStatus::Disabled;
             break;
     }
     $item->Type = TenantType::GetByID($values["tenant_TypeID"]);
     $item->PaymentPlan = PaymentPlan::GetByID($values["tenant_PaymentPlanID"]);
     $item->BeginTimestamp = $values["tenant_BeginTimestamp"];
     $item->EndTimestamp = $values["tenant_EndTimestamp"];
     // get the data centers associated with this tenant
     global $MySQL;
     $query = "SELECT " . System::$Configuration["Database.TablePrefix"] . "DataCenters.* FROM " . System::$Configuration["Database.TablePrefix"] . "DataCenters, " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters WHERE " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters.tdc_TenantID = " . $item->ID . " AND " . System::$Configuration["Database.TablePrefix"] . "TenantDataCenters.tdc_DataCenterID = " . System::$Configuration["Database.TablePrefix"] . "DataCenters.datacenter_ID";
     $result = $MySQL->query($query);
     $count = $result->num_rows;
     $retval = array();
     for ($i = 0; $i < $count; $i++) {
         $values = $result->fetch_assoc();
         $retval[] = DataCenter::GetByAssoc($values);
     }
     $item->DataCenters->Items = $retval;
     return $item;
 }
        $items = PaymentPlan::Get();
        $lv = new ListView();
        $lv->Columns = array(new ListViewColumn("chPaymentPlanTitle", "Title"), new ListViewColumn("chPaymentPlanDescription", "Description"));
        foreach ($items as $item) {
            $lv->Items[] = new ListViewItem(array(new ListViewItemColumn("chPaymentPlanTitle", "<a href=\"" . System::ExpandRelativePath("~/payment-plans/modify/" . $item->ID) . "\">" . $item->Title . "</a>"), new ListViewItemColumn("chPaymentPlanDescription", $item->Description)));
        }
        $lv->Render();
    }
}
System::$Modules[] = new \WebFX\Module("net.phoenixsns.TenantManager.PaymentPlan", array(new ModulePage("payment-plans", array(new ModulePage("", function ($page, $path) {
    $page = new PaymentPlanBrowsePage();
    $page->Render();
    return true;
}), new ModulePage("modify", function ($page, $path) {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        if (isset($_POST["paymentplan_ID"])) {
            $paymentplan = PaymentPlan::GetByID($_POST["paymentplan_ID"]);
        } else {
            $paymentplan = new PaymentPlan();
        }
        $paymentplan->Title = $_POST["paymentplan_Title"];
        $paymentplan->Description = $_POST["paymentplan_Description"];
        $paymentplan->Update();
        System::Redirect("~/payment-plans");
    } else {
        $page = new PaymentPlanModifyPage();
        $page->CurrentObject = PaymentPlan::GetByID($path[0]);
        $page->Render();
    }
    return true;
})))));
Ejemplo n.º 3
0
 public static function GetByAssoc($values)
 {
     $this->PaymentPlan = PaymentPlan::GetByID($values["paymentplanpayment_PaymentPlanID"]);
     $this->FixedAmount = $values["paymentplanpayment_FixedAmount"];
     $this->VariableAmount = $values["paymentplanpayment_VariableAmount"];
     $this->IntervalValue = $values["paymentplanpayment_IntervalValue"];
     $this->IntervalType = $values["paymentplanpayment_IntervalType"];
 }
Ejemplo n.º 4
0
        $page = new ConfirmOperationPage();
        $page->ReturnButtonURL = "~/tenant";
        $page->Message = "Are you sure you want to delete the tenant '" . $path[0] . "'? This action cannot be undone, and will destroy any and all data associated with that tenant.";
        $page->Render();
        return true;
    }
}), new ModulePage("modify", function ($page, $path) {
    if (!isset($path[1]) || $path[1] == "") {
        $tenant = Tenant::GetByURL($path[0]);
        System::$TenantName = $path[0];
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
            $tenant->URL = $_POST["tenant_URL"];
            $tenant->Description = $_POST["tenant_Description"];
            $tenant->Status = isset($_POST["tenant_Status"]) ? TenantStatus::Enabled : TenantStatus::Disabled;
            $tenant->Type = TenantType::GetByID($_POST["tenant_TypeID"]);
            $tenant->PaymentPlan = PaymentPlan::GetByID($_POST["tenant_PaymentPlanID"]);
            $tenant->BeginTimestamp = $_POST["tenant_BeginTimestampValid"] == "on" ? null : $_POST["tenant_BeginTimestamp"];
            $tenant->EndTimestamp = $_POST["tenant_EndTimestampValid"] == "on" ? null : $_POST["tenant_EndTimestamp"];
            $retval = $tenant->Update();
            if (!$retval) {
                global $MySQL;
                echo $MySQL->error . " (" . $MySQL->errno . ")";
            } else {
                System::$TenantName = $tenant->URL;
                $properties = $tenant->GetProperties();
                foreach ($properties as $property) {
                    $tenant->SetPropertyValue($property, $_POST["Property_" . $property->ID]);
                }
                System::Redirect("~/tenant");
            }
            return true;