Esempio n. 1
0
 public static function checkAll($entityType)
 {
     $counters = Counter::find("entityTypeId", $entityType)->all();
     foreach ($counters as $counter) {
         if ($counter->checkCounter()) {
             $counter->save();
         }
     }
 }
Esempio n. 2
0
 public function saveData()
 {
     $id = 0;
     $name = '';
     $counter_name = '';
     $date = '';
     $read = '';
     $type = '';
     foreach ($_REQUEST as $key => $value) {
         $id_row = preg_replace("/[^0-9]/", '', $key);
         if ($id != $id_row) {
             /*
              * @TODO Сделать проверку при вставке
              */
             $counter_isset = Counter::find('all', ['conditions' => ['YEAR(date) = ? and MONTH(date) = ? and counter =? and concetrator=?', explode('.', $date)[2], explode('.', $date)[1], $counter_name, $name]]);
             if (count($counter_isset) == 0) {
                 $counter = new Counter();
                 $counter->concetrator = $name;
                 $counter->counter = $counter_name;
                 $counter->date = $date;
                 $counter->reading = (int) $read;
                 $counter->type = $type;
                 $counter->save();
                 $id = $id_row;
                 $name = '';
                 $counter_name = '';
                 $date = '';
                 $read = '';
                 $type = '';
             }
         }
         $str = preg_replace("/[^a-zA-Z]/", '', $key);
         switch ($str) {
             case 'name':
                 $name = $value;
                 break;
             case 'counter':
                 $counter_name = $value;
                 break;
             case 'date':
                 $date = $value;
                 break;
             case 'read':
                 $read = $value;
                 break;
             case 'type':
                 $type = $value;
                 break;
             default:
                 break;
         }
     }
     Flight::redirect('/admin/update?success=1');
 }
Esempio n. 3
0
        <legend>Показания счетчика</legend>
        <table  class="table table-striped">
            <thead>
                <tr>	
                    <th>Пользователь</th>
                    <th>Последние показания</th>
                </tr>
            </thead>
            <tbody>
                <?php 
    $join = "INNER JOIN koncentrator_tovarishestvo c ON(user.concetrator = c.name_konc)";
    $users = User::all(array('conditions' => array("is_admin <> ? and id_tovar= ?", 1, $id), 'joins' => $join));
    if (!is_null($users)) {
        foreach ($users as $user) {
            $str = 'sum(reading)';
            $last = Counter::find('first', ['order' => 'date desc', 'conditions' => ['counter =? and concetrator=?', $user->counter, $user->concetrator]]);
            ?>
                        <tr>
                            <td><?php 
            echo $user->fio;
            ?>
</td>
                            <td><div data-toggle="modal" data-target="#squarespaceModal" class="center-block"><?php 
            echo $last->reading;
            ?>
</div></td>
                        </tr>
                        <?php 
        }
    }
    ?>
Esempio n. 4
0
			<div class=" col-md-15 well">
                            <legend>Показания счетчика</legend>
				<table  class="table table-striped">
					<thead>
						<tr>			
							<th>Дата</th>
							<th>Потребляемая энергия</th>
						</tr>
					</thead>
					<tbody>
                                        <?php 
$user = Auth::getInstance()->getUser();
$counter = Counter::find('all', ['select' => 'DISTINCT reading,date', 'conditions' => ['counter = ? and concetrator = ?', $user->counter, $user->concetrator], 'order' => 'date desc']);
foreach ($counter as $value) {
    ?>
                                            <tr>
                                                <td><?php 
    echo $value->date;
    ?>
</td>
                                                <td><div data-toggle="modal" data-target="#squarespaceModal" class="center-block"><?php 
    echo $value->reading;
    ?>
</div></td>
                                            </tr>
                                            <?php 
}
?>
                                        </tbody>
				</table>