當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Resources::getResourceIdByName方法代碼示例

本文整理匯總了PHP中Resources::getResourceIdByName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Resources::getResourceIdByName方法的具體用法?PHP Resources::getResourceIdByName怎麽用?PHP Resources::getResourceIdByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Resources的用法示例。


在下文中一共展示了Resources::getResourceIdByName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: findAvailableHardwareResource

 public static function findAvailableHardwareResource($resourceDb, $start, $end, $name)
 {
     //CHECK WETHER THERE IS A RESOURCE OF TYPE $type LEFT (COUNT $booked AGAINST $available???
     // NEEDED:
     //  -NR. OF RESOURCES OF TYPE $type
     //  -NR OF RESOUCRES LEFT AFTER SUBTRACTING $booked
     //  -ASSIGN A RESOURCE_ID IF POSSIBLE
     $hid = 0;
     $id = Resources::getResourceIdByName($name, $resourceDb);
     $numberOfResources = HardwareSchedule::getNrOfAvailableResources($id);
     $reservedResources = HardwareSchedule::getNrOfReservedHardwareResources($start, $end, $id);
     if ($numberOfResources - $reservedResources > 0) {
         $hid = HardwareSchedule::getBookableHardwareResources($start, $end, $id);
     } else {
         $error = Yii::app()->clientScript;
         $error->registerScript('error', 'alert("No resource ' . $name . ' Available!");', CClientScript::POS_READY);
     }
     return $hid;
 }
開發者ID:rknox,項目名稱:PPM-App,代碼行數:19,代碼來源:HardwareSchedule.php

示例2: actionAdd

 /**
  * Creates a new Resource.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param $type
  */
 public function actionAdd($type)
 {
     if ($type == 'employee') {
         $model = new Employees();
     } else {
         if ($type == 'hardware') {
             $model = new Hardware();
         } else {
             if ($type == 'facilities') {
                 $model = new Facilities();
             }
         }
     }
     if (isset($_POST['Employees']) || isset($_POST['Hardware']) || isset($_POST['Facilities'])) {
         if (get_class($model) == Employees) {
             $model->attributes = $_POST['Employees'];
             $model->e_type = Resources::getResourceIdByName($_POST['Employees']['e_type'], Resources::EMPLOYMENT_TYPES_DB);
         } else {
             if (get_class($model) == Hardware) {
                 $model->attributes = $_POST['Hardware'];
                 $model->h_type = Resources::getResourceIdByName($_POST['Hardware']['h_type'], Resources::HARDWARE_TYPES_DB);
             } else {
                 if (get_class($model) == Facilities) {
                     $model->attributes = $_POST['Facilities'];
                     $model->f_type = Resources::getResourceIdByName($_POST['Facilities']['f_type'], Resources::FACILITY_TYPES_DB);
                 }
             }
         }
         if ($model->save()) {
             $this->redirect(array('/resources'));
         }
     } else {
         $this->render('createResource', array('model' => $model));
     }
 }
開發者ID:rknox,項目名稱:PPM-App,代碼行數:40,代碼來源:ResourcesController.php


注:本文中的Resources::getResourceIdByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。