Beispiel #1
0
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();
                $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;
    }
}
Beispiel #2
0
             $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);
Beispiel #3
0
    $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');
Beispiel #4
0
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;
    }
}