public function testInvalidSensorId() { $invalidTest = array('measurement_id' => 1, 'measurement_index' => 1, 'measurement_value' => 98.59999999999999, 'measurement_timestamp' => '2015-11-21 18:15:23.123456', 'sensor_id' => -1, 'sensorType' => 'TEMPERATURE', 'sequenceType' => 'TIME_CODED'); $invalidMeasurement = new Measurement($invalidTest); $this->assertEquals(1, $invalidMeasurement->getErrorCount(), 'The Measurement object should have exactly 1 error'); $this->assertTrue(!empty($invalidMeasurement->getError('sensor_id')), 'The Measurement should have a sensor_id error'); }
public static function getMeasurementsArray($rows) { $measurements = array(); if (!empty($rows)) { // Convert the array of arrays into an array of Measurements // and set the id field foreach ($rows as $measurementRow) { $measurement = new Measurement($measurementRow); $measurementId = $measurementRow['measurement_id']; $measurement->setMeasurementId($measurementId); array_push($measurements, $measurement); } } return $measurements; }
public function readUnits() { $con = self::openConnection(); $measurements = new Measurements(); mysqli_begin_transaction($con); $sql = "SELECT * FROM measurement WHERE 1"; $res = mysqli_query($con, $sql); while ($arrRes = mysqli_fetch_assoc($res)) { $measurement = new Measurement(); $measurement->setId($arrRes['id']); $measurement->setCode($arrRes['code']); $measurements->setUnit($measurement); } return $measurements; }
public function testUpdateMeasurementValue() { $myDb = DBMaker::create('sensordatarepotest'); Database::clearDB(); $db = Database::getDB('sensordatarepotest', 'C:\\xampp\\myConfig.ini'); $testMeasurementId = 1; $measurements = MeasurementsDB::getMeasurementsBy('measurement_id', $testMeasurementId); $measurement = $measurements[0]; $this->assertEquals($measurement->getMeasurementValue(), '45.2', 'Before the update, the measurement should have value 45.2'); $params = $measurement->getParameters(); $params['measurement_value'] = '25.4'; $params['sensorType'] = 'HEADING'; $params['sequenceType'] = 'SEQUENTIAL'; $newMeasurement = new Measurement($params); $newMeasurement->setMeasurementId($testMeasurementId); $returnedMeasurement = MeasurementsDB::updateMeasurement($newMeasurement); $this->assertEquals($returnedMeasurement->getMeasurementValue(), $params['measurement_value'], 'After the update it should have the value ' . $params['measurement_value']); $this->assertTrue(empty($returnedMeasurement->getErrors()), 'The updated measurement should be error-free'); }
public static function fromArray(&$p) { $measurements = array(); if (isset($p['measurements'])) { foreach ($p['measurements'] as $measurement) { $measurements[] = Measurement::fromArray($measurement); } } return new Reading($p['id'], isset($p['observation_id']) ? $p['observation_id'] : null, isset($p['set_number']) ? $p['set_number'] : null, isset($p['declination_valid']) ? $p['declination_valid'] : null, isset($p['declination_shift']) ? $p['declination_shift'] : null, isset($p['horizontal_intensity_valid']) ? $p['horizontal_intensity_valid'] : null, isset($p['vertical_intensity_valid']) ? $p['vertical_intensity_valid'] : null, isset($p['startH']) ? $p['startH'] : null, isset($p['endH']) ? $p['endH'] : null, isset($p['absH']) ? $p['absH'] : null, isset($p['baseH']) ? $p['baseH'] : null, isset($p['startZ']) ? $p['startZ'] : null, isset($p['endZ']) ? $p['endZ'] : null, isset($p['absZ']) ? $p['absZ'] : null, isset($p['baseZ']) ? $p['baseZ'] : null, isset($p['startD']) ? $p['startD'] : null, isset($p['endD']) ? $p['endD'] : null, isset($p['absD']) ? $p['absD'] : null, isset($p['baseD']) ? $p['baseD'] : null, isset($p['annotation']) ? $p['annotation'] : null, $measurements); }
function getList($user, $type = 1, $offset = 0, $limit = 10) { if (!is_numeric($type)) { throw new Exception("Type is not recognized"); } $list = array(); $offset = $offset * $limit; $stmCount = $this->db->getConn()->prepare("SELECT COUNT(*) as c from `measurement` where type=:t and user_id=:u order by date desc"); $stmCount->bindParam(':t', $type); $stmCount->bindParam(':u', $user); $entryCount = $limit; if ($stmCount->execute()) { $row = $stmCount->fetch(PDO::FETCH_ASSOC); $entryCount = $row['c']; } $stmt = $this->db->getConn()->prepare("SELECT * from `measurement` where type = :t and user_id = :u order by date desc LIMIT :o , :l"); $stmt->bindParam(":t", $type); $stmt->bindParam(":o", $offset, PDO::PARAM_INT); $stmt->bindParam(":l", $limit, PDO::PARAM_INT); $stmt->bindParam(":u", $user); if ($stmt->execute()) { $lst = $stmt->fetchAll(PDO::FETCH_OBJ); $index = 0; $entries = array($limit); foreach ($lst as $entry) { $row = new Measurement($entry); if ($index + 1 < count($lst)) { $nxtEntry = $lst[$index + 1]; $row->difference = $entry->amount - $nxtEntry->amount; } if ($index < $limit) { $entries[$index] = $row->asArray(); } $index++; } $records = array_reverse($entries); $returnData = array(); $returnData['entries'] = $records; $returnData['records'] = intVal($entryCount); return $returnData; } }
<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'products-form', 'enableAjaxValidation' => false)); ?> <?php echo $form->errorSummary($model); ?> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 100)); ?> <br /> <div ><?php echo $form->dropDownListRow($model, 'measure_id', CHtml::listData(Measurement::model()->findAll(), 'measure_id', 'name'), array('class' => 'span2')); ?> </div> <div class="form-actions span9"> <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Сохранить' : 'Сохранить')); ?> </div> <script> var delay = (function(){ var timer = 0; return function(callback, ms){ clearTimeout (timer); timer = setTimeout(callback, ms);
<?php $dishes = new Dishes(); $measure = new Measurement(); $prod = new Products(); $stuff = new Halfstaff(); $count = 1; $dates = date('Y-m-d'); ?> <br> <script src="<?php echo Yii::app()->request->baseUrl; ?> /js/jquery.table2excel.js" type="text/javascript"></script> <script src="/js/jquery.printPage.js"></script> <?php echo CHtml::link('<i class="fa fa-print"></i> Печать', array('/settings/ajaxPrintCalculate?id=' . $id), array('class' => 'btn btnPrint')); ?> <button class="btn btn-success" id="export">Экспорт в excel</button><br><br> <table class="table" id="dataTable"> <tr> <?php foreach ($model as $val) { $cnt = 1; $summ = 0; ?> <?php if ($count % 4 + 1 == 0) { ?>
<?php require_once "../../require/conexion.class.php"; require_once "../../require/Block_Sensors.class.php"; require_once "../../require/Measurement.class.php"; require_once "../../require/Parameters.class.php"; require_once "../../require/Blocks.class.php"; $DataTime = array(); $DataValue = array(); $Data = array(); $lastID = 0; $long = 0; $Measurement = new Measurement(); $Block_Sensors = new Block_Sensors(); $Parameters = new Parameters(); $Blocks = new Blocks(); $id = (double) $_GET["BS"]; //$id = 2; //$time = $_GET["time_type"]; /* time_type= '24day' --> to show the last 24 hours time_type= '1Week' --> to show the last week time_type= 'All' --> to show all the information until now */ $Block = $Block_Sensors->getblock_byId($id); $ValParameters = $Parameters->getParameter_bySensor($Block["id_sensor"]); $ValBlock = $Blocks->getblock_byId($Block["id_block"]); $Measurement->get_last24hours($Block["id_sensor"]); $months = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']; $LimSup = (double) $Block["up_danger_limit"]; $LimInf = (double) $Block["up_risk_limit"];
public function actionAjaxDetail($depId, $key, $dates) { $model = array(); $model2 = array(); $model3 = array(); $expense = new Expense(); $prod = new Products(); $stuff = new Halfstaff(); $measure = new Measurement(); if ($key == 'begin') { $model = Yii::app()->db->createCommand()->select('db.startCount as count,db.prod_id,p.name as name,m.name as Mname')->from('dep_balance db')->join('products p', 'p.product_id = db.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll(); $model2 = Yii::app()->db->createCommand()->select('db.startCount as count,db.prod_id,h.name as name, m.name as Mname')->from('dep_balance db')->join('halfstaff h', 'h.halfstuff_id = db.prod_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll(); } if ($key == 'end') { $model = Yii::app()->db->createCommand()->select('db.endCount as count,db.prod_id,p.name as name,m.name as Mname')->from('dep_balance db')->join('products p', 'p.product_id = db.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll(); $model2 = Yii::app()->db->createCommand()->select('db.endCount as count,db.prod_id,h.name as name, m.name as Mname')->from('dep_balance db')->join('halfstaff h', 'h.halfstuff_id = db.prod_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll(); } if ($key == 'curEnd') { $model = Yii::app()->db->createCommand()->select('db.CurEndCount as count,db.prod_id,p.name as name,m.name as Mname')->from('dep_balance db')->join('products p', 'p.product_id = db.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 1))->queryAll(); $model2 = Yii::app()->db->createCommand()->select('db.CurEndCount as count,db.prod_id,h.name as name, m.name as Mname')->from('dep_balance db')->join('halfstaff h', 'h.halfstuff_id = db.prod_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('db.b_date = :dates AND db.department_id = :depId AND db.type = :types', array(':dates' => $dates, ':depId' => $depId, ':types' => 2))->queryAll(); } if ($key == 'realize') { $model = Yii::app()->db->createCommand()->select('dr.count as count,dr.prod_id,p.name as name,m.name as Mname')->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->join('products p', 'p.product_id = dr.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('date(df.real_date) = :dates AND df.department_id = :depId AND df.fromDepId = :fromDepId ', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0))->queryAll(); } if ($key == 'price') { $model = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,p.name as name,ex.mType,ord.type')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('products p', 'p.product_id = ord.just_id')->where('date(ex.order_date) = :dates AND p.department_id = :DepId AND ord.type = :type', array(':dates' => $dates, ':DepId' => $depId, ':type' => 3))->group('ord.just_id')->queryAll(); $model2 = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,h.name as name,ex.mType,ord.type')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('halfstaff h', 'h.halfstuff_id = ord.just_id')->where('date(ex.order_date) = :dates AND h.department_id = :DepId AND ord.type = :type', array(':dates' => $dates, ':DepId' => $depId, ':type' => 2))->group('ord.just_id')->queryAll(); $model3 = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,d.name as name,ex.mType,ord.type')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('dishes d', 'd.dish_id = ord.just_id')->where('date(ex.order_date) = :dates AND d.department_id = :DepId AND ord.type = :type', array(':dates' => $dates, ':DepId' => $depId, ':type' => 1))->group('ord.just_id')->queryAll(); } if ($key == 'other') { $model = Yii::app()->db->createCommand()->select('sum(ord.count) as count,ord.just_id as prod_id,p.name as name')->from('expense ex')->join('orders ord', 'ord.expense_id = ex.expense_id')->join('products p', 'p.product_id = ord.just_id')->where('date(ex.order_date) = :dates AND ex.kind = :kind AND ord.type = :type', array(':dates' => $dates, ':kind' => 1, ':type' => 3))->group('ord.just_id')->queryAll(); } if ($key == 'costPrice') { $temp = $expense->getDishProd($depId, $dates); $count = 0; foreach ($temp as $key => $val) { $model[$count]['count'] = $val; $model[$count]['prod_id'] = $key; $model[$count]['name'] = $prod->getName($key); $model[$count]['Mname'] = $measure->getMeasure($key, 'prod'); $count++; } $temp2 = $expense->getDishStuff($depId, $dates); $count = 0; foreach ($temp2 as $key => $val) { $model2[$count]['count'] = $val; $model2[$count]['prod_id'] = $key; $model2[$count]['name'] = $stuff->getName($key); $model2[$count]['Mname'] = $measure->getMeasure($key, 'stuff'); $count++; } /*$model = Yii::app()->db->createCommand() ->select('sum(ord.count) as count,ord.just_id as prod_id,p.name as name,ex.mType,ord.type') ->from('expense ex') ->join('orders ord','ord.expense_id = ex.expense_id') ->join('products p','p.product_id = ord.just_id') ->where('date(ex.order_date) = :dates AND p.department_id = :DepId AND ord.type = :type', array(':dates'=>$dates,':DepId'=>$depId,':type'=>3)) ->group('ord.just_id') ->queryAll(); $model2 = Yii::app()->db->createCommand() ->select('sum(ord.count) as count,ord.just_id as prod_id,h.name as name,ex.mType,ord.type') ->from('expense ex') ->join('orders ord','ord.expense_id = ex.expense_id') ->join('halfstaff h','h.halfstuff_id = ord.just_id') ->where('date(ex.order_date) = :dates AND h.department_id = :DepId AND ord.type = :type', array(':dates'=>$dates,':DepId'=>$depId,':type'=>2)) ->group('ord.just_id') ->queryAll(); $model3 = Yii::app()->db->createCommand() ->select('sum(ord.count) as count,ord.just_id as prod_id,d.name as name,ex.mType,ord.type') ->from('expense ex') ->join('orders ord','ord.expense_id = ex.expense_id') ->join('dishes d','d.dish_id = ord.just_id') ->where('date(ex.order_date) = :dates AND d.department_id = :DepId AND ord.type = :type', array(':dates'=>$dates,':DepId'=>$depId,':type'=>1)) ->group('ord.just_id') ->queryAll();*/ } if ($key == 'inRealize') { $model = Yii::app()->db->createCommand()->select('dr.count as count,dr.prod_id,p.name as name,m.name as Mname')->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->join('products p', 'p.product_id = dr.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('date(df.real_date) = :dates AND df.department_id = :depId AND df.fromDepId != :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0))->queryAll(); $model2 = Yii::app()->db->createCommand()->select('inord.count as count,inord.stuff_id as prod_id,h.name as name,m.name as Mname')->from('inexpense inexp')->join('inorder inord', 'inord.inexpense_id = inexp.inexpense_id')->join('halfstaff h', 'h.halfstuff_id = inord.stuff_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('date(inexp.inexp_date) = :dates AND inexp.department_id = :depId AND inexp.fromDepId != :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0))->queryAll(); } if ($key == 'inExp') { $model = Yii::app()->db->createCommand()->select('dr.count as count,dr.prod_id,p.name as name,m.name as Mname')->from('dep_faktura df')->join('dep_realize dr', 'dr.dep_faktura_id = df.dep_faktura_id')->join('products p', 'p.product_id = dr.prod_id')->join('measurement m', 'm.measure_id = p.measure_id')->where('date(df.real_date) = :dates AND df.department_id != :depId AND df.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId))->queryAll(); $model2 = Yii::app()->db->createCommand()->select('inord.count as count,inord.stuff_id as prod_id,h.name as name,m.name as Mname')->from('inexpense inexp')->join('inorder inord', 'inord.inexpense_id = inexp.inexpense_id')->join('halfstaff h', 'h.halfstuff_id = inord.stuff_id')->join('measurement m', 'm.measure_id = h.stuff_type')->where('date(inexp.inexp_date) = :dates AND inexp.department_id != :depId AND inexp.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => $depId))->queryAll(); } $this->renderPartial('ajaxDetail', array('dates' => $dates, 'model' => $model, 'model2' => $model2, 'model3' => $model3, 'key' => $key)); }
public function parseMeasurements() { $measurements = new Measurements(); $keyParams = array(); foreach ($this->xmlProducts as $product) { $bmu = $product->getBasicMeasurementUnit(); $mu = $product->getMeasurementUnit(); if (!empty($bmu) && !in_array($bmu, $keyParams)) { $measurement = new Measurement(); $measurement->setCode($bmu); $measurements->setUnit($measurement); array_push($keyParams, $bmu); } if (!empty($mu) && !in_array($mu, $keyParams)) { array_push($keyParams, $mu); $measurement = new Measurement(); $measurement->setCode($mu); $measurements->setUnit($measurement); } } $measurementDAO = new MeasurementDAO(); $measurementDAO->insertUnits($measurements); $measurements = $measurementDAO->readUnits(); return $measurements; }
$encoder = $_SESSION['sess_user_name']; } //$breakfile="amb_clinic_patients.php".URL_APPEND."&edit=$edit&dept_nr=$dept_nr"; $breakfile = "javascript:window.close();"; //if($backpath) $breakfile=urldecode($backpath).URL_APPEND; $thisfile = basename($_SERVER['PHP_SELF']); # Load date formatter require_once $root_path . 'include/inc_date_format_functions.php'; require_once $root_path . 'include/care_api_classes/class_encounter.php'; require_once $root_path . 'include/care_api_classes/class_tz_diagnostics.php'; include_once $root_path . 'language/en/lang_en_aufnahme.php'; //include_once($root_path.'language/en/obstetrics.php'); require_once $root_path . 'include/care_api_classes/class_measurement.php'; require_once $root_path . 'include/care_api_classes/class_mini_dental.php'; $oc = new dental(); $obj = new Measurement(); $fileNr = $oc->GetFileNoFromPID($pid); $unit_types = $obj->getUnits(); $unit_rates = $obj->rateUnits(); $unit_bp = $obj->pressureUnits(); $unit_temp = $obj->temperatureUnits(); # Prepare unit ids in array $unit_ids = array(); while (list($x, $v) = each($unit_types)) { $unit_ids[$v['nr']] = $v['id']; } reset($unit_types); while (list($x, $v) = each($unit_rates)) { $unit_ids[$v['nr']] = $v['id']; } reset($unit_rates);
public function __construct($quantity) { parent::__construct($quantity, $this->measurementUnit()); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionImport() { $model = new Measurement(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Measurement'])) { if (!empty($_FILES)) { $tempFile = $_FILES['Measurement']['tmp_name']['fileImport']; $fileTypes = array('xls', 'xlsx'); // File extensions $fileParts = pathinfo($_FILES['Measurement']['name']['fileImport']); if (in_array(@$fileParts['extension'], $fileTypes)) { Yii::import('ext.heart.excel.EHeartExcel', true); EHeartExcel::init(); $inputFileType = PHPExcel_IOFactory::identify($tempFile); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($tempFile); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $baseRow = 2; $inserted = 0; $read_status = false; while (!empty($sheetData[$baseRow]['A'])) { $read_status = true; //$measure_id= $sheetData[$baseRow]['A']; $name = $sheetData[$baseRow]['B']; $model2 = new Measurement(); //$model2->measure_id= $measure_id; $model2->name = $name; try { if ($model2->save()) { $inserted++; } } catch (Exception $e) { Yii::app()->user->setFlash('error', "{$e->getMessage()}"); //$this->refresh(); } $baseRow++; } Yii::app()->user->setFlash('success', $inserted . ' row inserted'); } else { Yii::app()->user->setFlash('warning', 'Wrong file type (xlsx, xls, and ods only)'); } } $this->render('admin', array('model' => $model)); } else { $this->render('admin', array('model' => $model)); } }
public function indexAction() { $query = Measurement::find("measurement_type = 2 order by date"); var_dump($query); exit; }
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'halfstaff-form', 'enableAjaxValidation' => false)); ?> <p class="note">Поля с <span class="required">*</span> обязательны.</p> <?php echo $form->errorSummary($model); ?> <div class="form-group"> <?php echo $form->textFieldRow($model, 'name', array('class' => 'span5')); ?> <br /> <div class="span3"><?php echo $form->dropDownListRow($model, 'stuff_type', CHtml::listData(Measurement::model()->findAll(), 'measure_id', 'name')); ?> </div> <div class="span3"><?php echo $form->textFieldRow($model, 'count', array()); ?> </div> <div > <div class=""> <div class="span3"> <h3>Продукты</h3> <?php echo $form->dropDownList($model, 'stuffStruct', $prodList, array('class' => 'span2 left all_options listbox', 'style' => 'height:200px!important', 'id' => 'all_product', 'empty' => 'Выберите продукт')); ?> </div>