當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。