当前位置: 首页>>代码示例>>PHP>>正文


PHP Resources::getResourceTypes方法代码示例

本文整理汇总了PHP中Resources::getResourceTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP Resources::getResourceTypes方法的具体用法?PHP Resources::getResourceTypes怎么用?PHP Resources::getResourceTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Resources的用法示例。


在下文中一共展示了Resources::getResourceTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $hardware = Resources::getResourceTypes(Resources::HARDWARE_DB);
     $employees = Resources::getResourceTypes(Resources::EMPLOYEE_DB);
     $facilities = Resources::getResourceTypes(Resources::FACILITY_DB);
     $customResources = new CustomResources();
     $resourceAvailable = 1;
     $projectId = $_GET['pid'];
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['create'])) {
         $ecounter = 0;
         $hcounter = 0;
         $fcounter = 0;
         $ccounter = 0;
         foreach ($_POST as $key => $value) {
             $resource = null;
             $type = $key;
             $type = substr($type, 0, 4);
             if ($value['start_date'] != '') {
                 if ($type == 'Empl') {
                     $resource = new EmployeeSchedule();
                     $resource->attributes = $_POST[$key];
                     $resource->employee_id = EmployeeSchedule::findAvailableEmployeeResource(Resources::EMPLOYEE_DB, $resource->start_date, $resource->end_date, $value['name']);
                     $resource->pid = $projectId;
                     if ($resource->employee_id == 0) {
                         $resource = null;
                         $resourceAvailable = 0;
                     }
                 } elseif ($type == 'Hard') {
                     $resource = new HardwareSchedule();
                     $resource->attributes = $_POST[$key];
                     $resource->pid = $projectId;
                     $resourceAvailable = HardwareSchedule::findAvailableHardwareResource(Resources::HARDWARE_TYPES_DB, $resource->start_date, $resource->end_date, $value['name']);
                     if ($resourceAvailable == 0) {
                         $resource = null;
                     } else {
                         $resource->hardware_id = $resourceAvailable;
                     }
                 } elseif ($type == 'Faci') {
                     $resource = new FacilitySchedule();
                     $resource->attributes = $_POST[$key];
                     $resource->pid = $projectId;
                     $resourceAvailable = FacilitySchedule::findAvailableFacilityResource(Resources::FACILITY_TYPES_DB, $resource->start_date, $resource->end_date, $value['name']);
                     if ($resourceAvailable == 0) {
                         $resource = null;
                     } else {
                         $resource->facility_id = $resourceAvailable;
                     }
                 } elseif ($type == 'Cust') {
                     $resource = new CustomResources();
                     $resource->attributes = $_POST[$key];
                     $resource->pid = $projectId;
                     $resource->owner = Yii::app()->user->id;
                     $ccounter++;
                 }
                 if ($resource != null) {
                     $resource->save();
                 }
             }
         }
         if ($resourceAvailable > 0) {
             $this->redirect(array('project/view', 'id' => $projectId));
         }
     }
     $employeeNames = Resources::getResourceNames(Resources::EMPLOYEE_DB);
     $this->render('create', array('employees' => $employees, 'employeeNames' => $employeeNames, 'hardware' => $hardware, 'facilities' => $facilities, 'customResources' => $customResources));
 }
开发者ID:rknox,项目名称:PPM-App,代码行数:72,代码来源:ResourcesController.php


注:本文中的Resources::getResourceTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。