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


PHP Device::getById方法代码示例

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


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

示例1: story_plugin_action

function story_plugin_action()
{
    global $_, $myUser;
    switch ($_['action']) {
        case 'plugin_story_get_type_template':
            Action::write(function ($_, &$response) {
                $templates = array_merge(Cause::types(), Effect::types());
                $template = $templates[$_['type']];
                preg_match_all("/(\\{)(.*?)(\\})/", $template['template'], $matches, PREG_SET_ORDER);
                foreach ($matches as $match) {
                    $template['template'] = str_replace($match[0], $_['data'][$match[2]], $template['template']);
                }
                /*
                $matches = preg_split("/\[(.*?)\]/", $template['template'],-1,PREG_SPLIT_DELIM_CAPTURE);
                
                $tpl = '';
                
                for($i=0;$i<count($matches);$i+=2){
                	$start = $matches[$i];
                	$var = $matches[$i+1];
                	list($name,$value) = explode(':',$var);
                	
                	
                	if($_['data'][$name] == $value) {
                		
                		$tpl.= 'selected="selected"';
                	}
                	$tpl.= $start;
                }
                $template['template'] = $tpl;
                */
                $response['html'] = '<li class="line" data-type="' . $_['type'] . '">
						<i class="fa ' . $template['icon'] . '"></i> <strong>' . $template['label'] . '</strong> ' . $template['template'] . ' <div class="delete"><i onclick="deleteLine(this);" class="fa fa-times"></i></div>
					</li>';
            }, array());
            break;
        case 'plugin_story_get_causes_effects':
            Action::write(function ($_, &$response) {
                $cause = new Cause();
                $effect = new Effect();
                $effects = $effect->loadAll(array('story' => $_['id']), 'sort');
                $causes = $cause->loadAll(array('story' => $_['id']), 'sort');
                foreach ($causes as $caus) {
                    $data = $caus->getValues();
                    $response['results'][] = array('type' => $caus->type, 'panel' => "CAUSE", 'data' => array('value' => $data->value, 'target' => $data->target, 'operator' => $data->operator, 'union' => $data->union));
                }
                foreach ($effects as $eff) {
                    $data = $eff->getValues();
                    $response['results'][] = array('type' => $eff->type, 'panel' => "EFFECT", 'data' => array('value' => $data->value, 'target' => $data->target, 'operator' => $data->operator, 'union' => $data->union));
                }
            }, array());
            break;
        case 'plugin_story_get_captors_plugins':
            Action::write(function ($_, &$response) {
                $deviceManager = new Device();
                $devices = $deviceManager->loadAll(array('state' => 1, 'type' => Device::CAPTOR));
                $response['plugins'] = array();
                foreach ($devices as $device) {
                    if (!isset($response['plugins'][$device->plugin])) {
                        $response['plugins'][] = $device->plugin;
                    }
                }
            }, array());
            break;
        case 'plugin_story_get_captors':
            Action::write(function ($_, &$response) {
                $deviceManager = new Device();
                $devices = $deviceManager->loadAll(array('state' => 1, 'plugin' => $_['plugin'], 'type' => Device::CAPTOR));
                foreach ($devices as $device) {
                    $response['devices'][] = array('plugin' => $device->plugin, 'label' => $device->label, 'id' => $device->id);
                }
            }, array());
            break;
        case 'plugin_story_get_captor_values':
            Action::write(function ($_, &$response) {
                $deviceManager = new Device();
                $device = $deviceManager->getById($_['id']);
                $response['values'] = $device->getValues();
            }, array());
            break;
        case 'plugin_story_delete_story':
            Action::write(function ($_, &$response) {
                $storyManager = new Story();
                $causeManager = new Cause();
                $effectManager = new Effect();
                $storyManager->delete(array('id' => $_['id']));
                $causeManager->delete(array('story' => $_['id']));
                $effectManager->delete(array('story' => $_['id']));
            }, array());
            break;
        case 'plugin_story_check':
            require_once dirname(__FILE__) . '/Cause.class.php';
            $vocal = new Cause();
            $vocal = $vocal->getById($_['event']);
            Story::check($vocal);
            break;
        case 'plugin_story_save_story':
            Action::write(function ($_, &$response) {
                $causeManager = new Cause();
                $effectManager = new Effect();
//.........这里部分代码省略.........
开发者ID:maditnerd,项目名称:yana-server,代码行数:101,代码来源:story.plugin.php

示例2: date

             $worksheet->write($index, 7, "=D{$count}+E{$count}-F{$count}+G{$count}", $row);
             $index++;
             $count++;
             $stt++;
         }
         $worksheet->write($index, 6, 'Tổng tiền trong tuần', $sum);
         $count = $count - 1;
         $worksheet->write($index, 7, "=SUM(H6:H{$count})", $sum);
     }
     $workbook->send('BaoCaoTuan_' . date('d-m-Y') . '.xls');
 } else {
     $month = $_POST['month'];
     $date_from = strtotime($month . '/01/' . date('Y'));
     $date_to = strtotime($month . '/31/' . date('Y'));
     if ($_POST['device']) {
         $device = Device::getById($_POST['device']);
         $worksheet->write(0, 0, 'Báo cáo tháng', $header);
         $worksheet->setMerge(0, 0, 0, 7);
         $worksheet->write(1, 6, 'Máy', $common);
         $worksheet->write(1, 7, $device->get_name(), $common);
         $worksheet->write(2, 6, 'Tháng', $common);
         $worksheet->write(2, 7, date('m/Y', $date_from), $common);
         $worksheet->write(3, 6, 'Ngày báo cáo', $common);
         $worksheet->write(3, 7, date('d/m/Y'), $common);
         $worksheet->write(5, 0, 'STT', $caption);
         $worksheet->write(5, 1, 'Giờ bắt đầu', $caption);
         $worksheet->write(5, 2, 'Giờ kết thúc', $caption);
         $worksheet->write(5, 3, 'Tiền giờ', $caption);
         $worksheet->write(5, 4, 'Tiền phụ thu', $caption);
         $worksheet->write(5, 5, 'Tiền giảm giá', $caption);
         $worksheet->write(5, 6, 'Tiền thực đơn', $caption);
开发者ID:nguyentien,项目名称:ps3,代码行数:31,代码来源:system.php

示例3:

    $p->set_surcharge(0);
    $p->set_discount(0);
    $p->set_comment('');
    $p->set_status(1);
    $p->set_date(strtotime('now'));
    $payment_id = Payment::save($p);
    exit;
}
if (!empty($_GET['switch'])) {
    // Update status of old device
    $d = Device::getById($device_id);
    $d->set_status(0);
    Device::save($d);
    // Update status of new device
    $device_id = (int) $_GET['new_device_id'];
    $d = Device::getById($device_id);
    $d->set_status(1);
    Device::save($d);
    $p = Payment::getById($payment_id);
    $p->set_device($device_id);
    Payment::save($p);
    echo $device_id;
    exit;
}
$smarty->assign('start', $start);
$smarty->assign('stop', $stop);
$smarty->assign('total', $total);
$smarty->assign('total1', $total1);
$smarty->assign('payment', Payment::getById($payment_id));
$smarty->assign('device', $device);
$smarty->display('payment.tpl');
开发者ID:nguyentien,项目名称:ps3,代码行数:31,代码来源:payment.php

示例4: story_plugin_action

function story_plugin_action()
{
    global $_, $myUser;
    switch ($_['action']) {
        case 'plugin_story_get_type_template':
            Action::write(function ($_, &$response) {
                $templates = array_merge(Cause::types(), Effect::types());
                $template = $templates[$_['type']];
                $response['html'] = '<li class="line" data-type="' . $_['type'] . '">
						<i class="fa ' . $template['icon'] . '"></i> <strong>' . $template['label'] . '</strong> ' . $template['template'] . ' <div class="delete"><i onclick="deleteLine(this);" class="fa fa-times"></i></div>
					</li>';
            }, array());
            break;
        case 'plugin_story_get_captors_plugins':
            Action::write(function ($_, &$response) {
                $deviceManager = new Device();
                $devices = $deviceManager->loadAll(array('state' => 1, 'type' => Device::CAPTOR));
                $response['plugins'] = array();
                foreach ($devices as $device) {
                    if (!isset($response['plugins'][$device->plugin])) {
                        $response['plugins'][] = $device->plugin;
                    }
                }
            }, array());
            break;
        case 'plugin_story_get_captors':
            Action::write(function ($_, &$response) {
                $deviceManager = new Device();
                $devices = $deviceManager->loadAll(array('state' => 1, 'plugin' => $_['plugin'], 'type' => Device::CAPTOR));
                foreach ($devices as $device) {
                    $response['devices'][] = array('plugin' => $device->plugin, 'label' => $device->label, 'id' => $device->id);
                }
            }, array());
            break;
        case 'plugin_story_get_captor_values':
            Action::write(function ($_, &$response) {
                $deviceManager = new Device();
                $device = $deviceManager->getById($_['id']);
                $response['values'] = $device->getValues();
            }, array());
            break;
        case 'plugin_story_delete_story':
            Action::write(function ($_, &$response) {
                $storyManager = new Story();
                $causeManager = new Cause();
                $effectManager = new Effect();
                $storyManager->delete(array('id' => $_['id']));
                $causeManager->delete(array('story' => $_['id']));
                $effectManager->delete(array('story' => $_['id']));
            }, array());
            break;
        case 'plugin_story_check':
            require_once dirname(__FILE__) . '/Cause.class.php';
            $vocal = new Cause();
            $vocal = $vocal->getById($_['event']);
            Story::check($vocal);
            break;
        case 'plugin_story_save_story':
            Action::write(function ($_, &$response) {
                $causeManager = new Cause();
                $effectManager = new Effect();
                $story = new Story();
                if (isset($_['story']['id']) && $_['story']['id'] != '0') {
                    $story = $story->getById($_['story']['id']);
                    $causeManager->delete(array('story' => $story->id));
                    $effectManager->delete(array('story' => $story->id));
                }
                $story->label = $_['story']['label'];
                $story->date = time();
                $story->state = 1;
                $story->save();
                $i = 0;
                foreach ($_['story']['causes'] as $cause) {
                    $current = new Cause();
                    $current->type = $cause['type'];
                    $current->operator = @$cause['operator'];
                    $current->setValues($cause);
                    $current->sort = $i;
                    $current->union = $cause['union'];
                    $current->story = $story->id;
                    $current->save();
                    $i++;
                }
                $i = 0;
                foreach ($_['story']['effects'] as $effect) {
                    $current = new Effect();
                    $current->type = $effect['type'];
                    $current->setValues($effect);
                    $current->sort = $i;
                    $current->union = $cause['union'];
                    $current->story = $story->id;
                    $current->save();
                    $i++;
                }
            }, array());
            break;
    }
}
开发者ID:kofeve,项目名称:yana-server,代码行数:98,代码来源:story.plugin.php


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