コード例 #1
0
ファイル: PlanRestriction.php プロジェクト: yasirgit/hotmall
 public static function getPlanLimitsForResource($resourceType, $advertiserId)
 {
     if ($resourceType == '') {
         return array();
     }
     $planType = PlanResourceType::getPlanType($resourceType);
     if ($planType == PlanType::ADVERTISER_PLAN) {
         if ($advertiserId == '') {
             $advertiserId = Yii::app()->user->getAdvertiserId();
         }
     }
     // get some payment plan
     $sql = "SELECT plan_id, type, duration, expired FROM p_purchased_plans" . " WHERE wlabel_id=" . Yii::app()->user->getWhiteLabelId() . " AND expired=0";
     if ($planType == PlanType::ADVERTISER_PLAN && $advertiserId != '') {
         $sql .= " AND advertiser_id=" . $advertiserId;
     }
     $sql .= " AND pplan_id in (" . "   SELECT pplan_id from p_purchased_plans_payments" . "     WHERE date_expire>='" . date("Y-m-d 00:00:00") . "'" . "   )";
     $dbCommand = Yii::app()->db->createCommand($sql);
     $results = $dbCommand->queryAll();
     if ($results == null) {
         // it is still possible that the plan is paid by authorize.net and lastpayment expired, check its status
         $results = PlanRestriction::checkAuthorizeNetPlans($planType, $advertiserId);
     }
     if ($results == null) {
         return 0;
     }
     $planIds = array();
     foreach ($results as $result) {
         $planIds[] = $result['plan_id'];
     }
     // now check for planlimits with this resource type
     $criteria = new CDbCriteria();
     $criteria->compare('t.plan_id', $planIds);
     $criteria->compare('t.resource_type', $resourceType);
     $result = PlanLimit::model()->find($criteria);
     if ($result == false) {
         return -1;
     }
     return $result->limit_amount;
 }
コード例 #2
0
ファイル: PlanLimit.php プロジェクト: yasirgit/hotmall
 public function getType($type)
 {
     return PlanResourceType::getType($type);
 }
コード例 #3
0
ファイル: view.php プロジェクト: yasirgit/hotmall
?>
</div>
<div class="portlet-content">

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('p_whitelabel.name', 'p_plans.name', 'date_created', 'p_plans.duration', 'method', 'price')));
?>

<br/><br/>
<div class="title title-spacing">
<h3>Plan Limitations</h3>
</div>

<?php 
if ($modelLimits != null) {
    $this->widget('zii.widgets.grid.CGridView', array('id' => 'purchased-plan-limit-grid', 'dataProvider' => $modelLimits->getLimits($model->plan_id), 'filter' => null, 'enableSorting' => false, 'columns' => array(array('name' => 'resource_type', 'filter' => CHtml::listData(PlanResourceType::findAllByType(PlanType::ADVERTISER_PLAN), 'id', 'name'), 'value' => '$data->getType($data->resource_type)'), 'limit_amount', array('class' => 'CButtonColumn', 'template' => ''))));
} else {
    echo "No limitations defined!";
}
?>


<br/><br/>
<div class="title title-spacing">
<h3>Plan Payments</h3>
</div>

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'purchased-plan-limit-grid', 'dataProvider' => $modelPayments->search($model->pplan_id), 'filter' => null, 'enableSorting' => false, 'columns' => array('date_paid', 'date_expire', 'transaction_id', array('class' => 'CButtonColumn', 'template' => ''))));
?>
コード例 #4
0
ファイル: _formPlanLimit.php プロジェクト: yasirgit/hotmall
echo $form->labelEx($modelPlanLimit, 'limit_amount');
?>
		<?php 
echo $form->textField($modelPlanLimit, 'limit_amount', array('class' => "full"));
?>
		<?php 
echo $form->error($modelPlanLimit, 'limit_amount');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($modelPlanLimit, 'resource_type');
?>
		<?php 
echo $form->dropDownList($modelPlanLimit, 'resource_type', CHtml::listData(PlanResourceType::findAllByType(PlanType::ADVERTISER_PLAN), 'id', 'name'));
?>
		<?php 
echo $form->error($modelPlanLimit, 'resource_type');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($modelPlanLimit, 'plan_id');
?>
		<?php 
echo $form->dropDownList($modelPlanLimit, 'plan_id', CHtml::listData(Plan::model()->findAllByType(PlanType::ADVERTISER_PLAN), 'plan_id', 'name'));
?>
		
		<?php 
コード例 #5
0
ファイル: PlanResourceType.php プロジェクト: yasirgit/hotmall
 public static function getPlanType($type)
 {
     $types = PlanResourceType::getAllTypes();
     foreach ($types[PlanType::ADVERTISER_PLAN] as $resourceType) {
         foreach ($resourceType as $id => $name) {
             if ($type == $id) {
                 return PlanType::ADVERTISER_PLAN;
             }
         }
     }
     foreach ($types[PlanType::WHITELABEL_PLAN] as $resourceType) {
         foreach ($resourceType as $id => $name) {
             if ($type == $id) {
                 return PlanType::WHITELABEL_PLAN;
             }
         }
     }
     return null;
 }
コード例 #6
0
ファイル: index.php プロジェクト: yasirgit/hotmall
    ?>
	
		

<div class="portlet">
<div class="portlet-header">Limit Plans</div>
<div class="portlet-content">

<?php 
    echo $this->renderPartial('_formPlanLimit', array('modelPlanLimit' => $modelPlanLimit));
    ?>
</div>
</div>


<div class="portlet">
<div class="portlet-header">View Plans</div>
<div class="portlet-content">


<?php 
    $this->widget('zii.widgets.grid.CGridView', array('id' => 'plan-limit-grid', 'dataProvider' => $modelPlanLimit->search(PlanType::ADVERTISER_PLAN), 'filter' => null, 'columns' => array(array('name' => 'plan_id', 'filter' => CHtml::listData(Plan::model()->findAllByType(PlanType::ADVERTISER_PLAN), 'plan_id', 'name'), 'value' => '$data->p_plans->name'), array('name' => 'resource_type', 'filter' => CHtml::listData(PlanResourceType::findAllByType(PlanType::ADVERTISER_PLAN), 'id', 'name'), 'value' => '$data->getType($data->resource_type)'), 'limit_amount', array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'buttons' => array('update' => array('label' => 'Update', 'url' => 'Yii::app()->createUrl("siteadmin/plan/updateLimit", array("id"=>$data->plimit_id))'), 'delete' => array('label' => 'Delete', 'url' => 'Yii::app()->createUrl("siteadmin/plan/deleteLimit", array("id"=>$data->plimit_id))'))))));
    ?>
</div>
</div>

<?php 
}
?>