public function __construct()
 {
     $this->equipment = Equipment::getAll();
     $this->categories = array();
     $cats = EquipmentCategory::getAll();
     foreach ($cats as $cat) {
         $cats_data = array();
         $cats_data['name'] = $cat->getName();
         $cats_data['items'] = $cat->countEquipment();
         $cats_data['tickets'] = $cat->countOpenTickets();
         $this->categories[] = $cats_data;
     }
     $this->status = array();
     $stats = EquipmentStatus::getAll();
     foreach ($stats as $stat) {
         $stat_data = array();
         $stat_data['name'] = $stat->getName();
         $stat_data['items'] = $stat->countEquipment();
         $this->status[] = $stat_data;
     }
     $this->tickets = 0;
     foreach ($this->categories as $cat) {
         $ticket_count = $cat['tickets'];
         if (isset($ticket_count)) {
             $this->tickets += $ticket_count;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 创建玩家装备
  * @param $intEquipmentId
  * @param $intPlayerId
  * @param int $intPlus
  */
 public function createOwnedEquipment($intEquipmentId, $intPlayerId, $intPlus = 0)
 {
     // 取得装备实例
     $objEquipment = Equipment::find($intEquipmentId);
     // 主属性随机值
     $this->status_1_add = mt_rand(0, $objEquipment->status_1_add);
     $this->status_2_add = mt_rand(0, $objEquipment->status_2_add);
     $this->status_3_add = mt_rand(0, $objEquipment->status_3_add);
     // 附加属性的计算
     // 取得稀有度
     $intRare = $objEquipment->rare;
     // 抽选用稀有度文字列 TODO
     $strRateType = "rate_low";
     // 抽选Type
     if ($intRare < 7) {
         $strRateType = "rate_middle";
     } else {
         $strRateType = "rate_high";
     }
     // 抽选List
     $lstAddStatuses = EquipmentStatus::all();
     // 装备的加值 每加1 多一种随机属性 且根据稀有度随机上下限
     $intPlusCount = 0;
     while ($intPlusCount < $intPlus) {
         $addStatus = $this->_drawing($lstAddStatuses->toArray(), $strRateType);
         $minValue = $addStatus['min_value'] * $intRare;
         $maxValue = $addStatus['max_value'] * $intRare;
         $intPlusCount++;
         switch ($intPlusCount) {
             case 1:
                 $this->addition_1_status_id = $addStatus['id'];
                 $this->addition_1_value = mt_rand($minValue, $maxValue);
                 break;
             case 2:
                 $this->addition_2_status_id = $addStatus['id'];
                 $this->addition_2_value = mt_rand($minValue, $maxValue);
                 break;
             case 3:
                 $this->addition_3_status_id = $addStatus['id'];
                 $this->addition_3_value = mt_rand($minValue, $maxValue);
                 break;
             case 4:
                 $this->addition_4_status_id = $addStatus['id'];
                 $this->addition_4_value = mt_rand($minValue, $maxValue);
                 break;
             default:
                 # code...
                 break;
         }
     }
     // 其他属性设定
     $this->player_id = $intPlayerId;
     $this->equipment_id = $objEquipment->id;
     $this->plus = $intPlus;
     $this->equipment_type_id = $objEquipment->type;
     $this->setUpStatus();
 }
Ejemplo n.º 3
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $model->equipment_type_id = $model->modelo->equipment_type_id;
     $model->brand_id = $model->modelo->brand_id;
     $modelFailureDescription = FailureDescription::model()->find('order_id =' . $model->id);
     if (!empty($modelFailureDescription)) {
         $model->_failureDescription = $modelFailureDescription->description;
     }
     $modelEquipment_status = EquipmentStatus::model()->find('order_id =' . $model->id);
     if (!empty($modelEquipment_status)) {
         $model->_equipmentStatus = $modelEquipment_status->description;
     }
     $modelServiceOrder = ServiceOrder::model()->find('order_id=' . $model->id);
     if (!empty($modelServiceOrder)) {
         $model->service = $modelServiceOrder->service_id;
     }
     $modelAccesoryOrder = AccesoryOrder::model()->findAll('order_id =' . $model->id);
     if (!empty($modelAccesoryOrder)) {
         $model->accesory = array();
         foreach ($modelAccesoryOrder as $accesoryOrder) {
             $model->accesory[] = $accesoryOrder->accesory_id;
         }
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->observation = $_POST['Order']['observation'];
         $model->attributes = $_POST['Order'];
         if ($model->save()) {
             if (!empty($modelAccesoryOrder)) {
                 AccesoryOrder::model()->deleteAll('order_id=' . $model->id);
             }
             if (isset($_POST['Order']['accesory'])) {
                 $accessories = $_POST['Order']['accesory'];
                 foreach ($accessories as $accesory) {
                     $modelAccesoryOrder = new AccesoryOrder();
                     $modelAccesoryOrder->order_id = $model->id;
                     $modelAccesoryOrder->accesory_id = $accesory;
                     $modelAccesoryOrder->save();
                 }
             }
             if (empty($modelFailureDescription)) {
                 $modelFailureDescription = new FailureDescription();
                 $modelFailureDescription->order_id = $model->id;
                 $modelFailureDescription->description = $_POST['Order']['_failureDescription'];
                 $modelFailureDescription->save();
             } else {
                 $modelFailureDescription->description = $_POST['Order']['_failureDescription'];
                 $modelFailureDescription->save();
             }
             if (empty($modelEquipment_status)) {
                 $modelEquipment_status = new EquipmentStatus();
                 $modelFailureDescription->order_id = $model->id;
                 $modelEquipment_status->description = $_POST['Order']['_equipmentStatus'];
                 $modelEquipment_status->save();
             } else {
                 $modelEquipment_status->description = $_POST['Order']['_equipmentStatus'];
                 $modelEquipment_status->save();
             }
             if (empty($modelServiceOrder)) {
                 $modelServiceOrder = new ServiceOrder();
                 $modelServiceOrder->order_id = $model->id;
                 $modelServiceOrder->service_id = $_POST['Order']['service'];
                 $modelServiceOrder->date = date('Y-m-d H:i:s');
                 $service = Service::model()->findByPk($modelServiceOrder->service_id);
                 $modelServiceOrder->price = $service->price;
                 $modelServiceOrder->save();
             } else {
                 $modelServiceOrder->service_id = $_POST['Order']['service'];
                 $modelServiceOrder->save();
             }
             $log = new BlogOrder();
             $log->order_id = $model->id;
             $log->activity = "Se modificó la orden con ID: " . $model->id;
             $log->detailed_activity = $this->renderPartial('view', array('model' => $model), true);
             $log->user_technical_id = Yii::app()->user->id;
             $log->date_hour = date('Y-m-d H:i:s');
             $log->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'modelAccesoryOrder' => $modelAccesoryOrder, 'modelEquipment_status' => $modelEquipment_status, 'modelFailureDescription' => $modelFailureDescription, 'modelServiceOrder' => $modelServiceOrder));
 }