本文整理汇总了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;
}
示例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));
}
}