Пример #1
0
function get_data($stats, $cathegory = '')
{
    foreach ($stats as $c => $d) {
        // if we have only one line in graphe
        if (strpos($d, ".json") != false) {
            $data = array($d);
            $name = array($c);
            make_graphe($cathegory, $data, $name);
        } elseif (GETTYPE($d) == 'array') {
            // some excetions for building some lines in graphe
            if (array_key_exists('read_bytes', $d) || array_key_exists('write_bytes', $d)) {
                $data = array($d['read_bytes'], $d['write_bytes']);
                $name = array('read_bytes', 'write_bytes');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['read_bytes']);
                unset($d['write_bytes']);
            }
            if ((array_key_exists('used', $d) || array_key_exists('size', $d)) && $c == 'filesystem') {
                $data = array($d['used'], $d['size']);
                $name = array('used', 'size');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['used']);
                unset($d['size']);
            }
            if (array_key_exists('tx', $d) || array_key_exists('rx', $d) || array_key_exists('cx', $d)) {
                $data = array($d['tx'], $d['rx'], $d['cx']);
                $name = array('tx', 'rx', 'cx');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['tx']);
                unset($d['rx']);
                unset($d['cx']);
            }
            if (array_key_exists('cumulative_tx', $d) || array_key_exists('cumulative_rx', $d) || array_key_exists('cumulative_cx', $d)) {
                $data = array($d['cumulative_tx'], $d['cumulative_rx'], $d['cumulative_cx']);
                $name = array('cumulative_tx', 'cumulative_rx', 'cumulative_cx');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['cumulative_tx']);
                unset($d['cumulative_rx']);
                unset($d['cumulative_cx']);
            }
            if ((array_key_exists('running', $d) || array_key_exists('thread', $d) || array_key_exists('sleeping', $d) || array_key_exists('total', $d)) && $c == 'process') {
                $data = array($d['running'], $d['thread'], $d['sleeping'], $d['total']);
                $name = array('running', 'thread', 'sleeping', 'total');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['running']);
                unset($d['thread']);
                unset($d['sleeping']);
                unset($d['total']);
            }
            if ($c == 'sensors') {
                $data = array();
                $name = array();
                $n = 0;
                foreach ($d as $a => $b) {
                    $data[$n] = $b['value'];
                    $name[$n] = $a;
                    unset($d[$a]);
                    $n++;
                }
                make_graphe("{$cathegory} - {$c}", $data, $name);
            }
            if (array_key_exists('guest', $d) || array_key_exists('softirq', $d) || array_key_exists('irq', $d) || array_key_exists('system', $d) || array_key_exists('idle', $d) || array_key_exists('user', $d) || array_key_exists('guest_nice', $d) || array_key_exists('iowait', $d) || array_key_exists('steal', $d) || array_key_exists('nice', $d)) {
                $data = array($d['guest'], $d['softirq'], $d['irq'], $d['system'], $d['idle'], $d['user'], $d['guest_nice'], $d['iowait'], $d['steal'], $d['nice']);
                $name = array('guest', 'softirq', 'irq', 'system', 'idle', 'user', 'guest_nice', 'iowait', 'steal', 'nice');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['guest']);
                unset($d['softirq']);
                unset($d['irq']);
                unset($d['system']);
                unset($d['idle']);
                unset($d['user']);
                unset($d['guest_nice']);
                unset($d['iowait']);
                unset($d['steal']);
                unset($d['nice']);
            }
            if ((array_key_exists('available', $d) || array_key_exists('used', $d) || array_key_exists('cached', $d) || array_key_exists('free', $d) || array_key_exists('active', $d) || array_key_exists('inactive', $d) || array_key_exists('total', $d) || array_key_exists('buffers', $d)) && $c == 'ram') {
                $data = array($d['available'], $d['used'], $d['cached'], $d['free'], $d['active'], $d['inactive'], $d['total'], $d['buffers']);
                $name = array('available', 'used', 'cached', 'free', 'idle', 'active', 'inactive', 'total', 'buffers');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['available']);
                unset($d['used']);
                unset($d['cached']);
                unset($d['free']);
                unset($d['active']);
                unset($d['inactive']);
                unset($d['total']);
                unset($d['buffers']);
                unset($d['ram']);
            }
            if ((array_key_exists('used', $d) || array_key_exists('free', $d) || array_key_exists('total', $d)) && $c == 'swap') {
                $data = array($d['used'], $d['free'], $d['total']);
                $name = array('used', 'free', 'total');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['used']);
                unset($d['free']);
                unset($d['total']);
            }
            if ((array_key_exists('sin', $d) || array_key_exists('sout', $d)) && $c == 'swap') {
                $data = array($d['sin'], $d['sout']);
                $name = array('sin', 'sout');
                make_graphe("{$cathegory} - {$c}", $data, $name);
                unset($d['sin']);
                unset($d['sout']);
            }
            // go down the hierarchy of stats if we haven't exection
            if (empty($d) == false) {
                get_data($d, "{$cathegory} - {$c}");
            }
        }
    }
}
Пример #2
0
 public function actionConfirmaanulacionsalidareserva($id)
 {
     $movimiento = '20';
     $model = $this->loadModel($id);
     $model->setscenario("anulacargainicial");
     if (isset($_POST['Almacendocs'])) {
         $model->attributes = $_POST['Almacendocs'];
         //iniciamos la transaccion
         $model->cestadovale = '20';
         $transaccion = $model->dbConnection->beginTransaction();
         $mensa = "";
         if ($model->save()) {
             $registroshijos = $this->devuelvehijos($model->id);
             foreach ($registroshijos as $row) {
                 $modeloinventario = $this->actualizainventario($row);
                 $registrodesolpe = Desolpe::model()->findByPk($row->idref);
                 $mensa .= GETTYPE($modeloinventario) == 'object' ? "" : $modeloinventario;
                 if (GETTYPE($modeloinventario) == 'object') {
                     $modeloinventario->setScenario('modificacantidad');
                     if (!$modeloinventario->save()) {
                         $mensa .= "Hubo un error al actualizar el inventario <br>";
                     }
                     $this->actualizacostos($modeloinventario, $row, $registrodesolpe, $registrodesolpe->tipimputacion, $registrodesolpe->tipsolpe);
                 }
                 $this->Actualizaatenciones($registrodesolpe, $row);
                 $row->setScenario('cambioestado');
                 $row->valido = '1';
                 $row->codestado = '10';
                 if (!$row->save()) {
                     $mensa .= "Error al momento de cambiar el estado del Kardex del material " . $row->codart;
                 }
             }
             //Ahora actualizamos el status del vale original, ANULARLO !!!!
             $valeoriginal = Almacendocs::model()->find("numvale=:vnumvale", array(":vnumvale" => trim($model->numdocref)));
             $valeoriginal->setScenario('cambioestado');
             $valeoriginal->cestadovale = '30';
             //anulado
             if (!$valeoriginal->save()) {
                 $mensa .= "Error al momento de cambiar el estado del Vale del material " . $valeoriginal->numvale;
             }
             if (strlen($mensa) == 0) {
                 //Si s epudo actualziar
                 $transaccion->commit();
                 Yii::app()->user->setFlash('success', "Se genero  el documento!" . $mensa);
                 $this->render('update', array('model' => $model, 'movimiento' => $movimiento));
                 yii::app()->end();
             } else {
                 $transaccion->rollback();
                 Yii::app()->user->setFlash('error', "No se pudo grabar el documento, hay  errores  :" . $mensa);
                 $model->refresh();
                 $this->render('update', array('model' => $model, 'movimiento' => $movimiento));
                 yii::app()->end();
                 //$model->refresh();
             }
         } else {
             // en caso de error
             $transaccion->rollback();
             Yii::app()->user->setFlash('error', "No se pudo grabar el documento :" . $mensa);
             $model->refresh();
             $this->render('update', array('model' => $model, 'movimiento' => $movimiento));
             yii::app()->end();
         }
     } else {
         $movimiento = 'Confirmaanulacargainicial';
         $this->render('update', array('model' => $model, 'movimiento' => $movimiento));
     }
     /*if($model->save()) {
     				//Yii::app()->end();
     				$this->actualizasolpe($movimiento,$model,$transaccion);
     				$this->actualizacostes($model,$transaccion);
     				$this->actualizahijos($movimiento,$model,$transaccion);
     				//$this->generacontabilidad($model);				
     				//finalizamos la transaccion
     				$transaccion->commit();
     				//$this->redirect(array('view','id'=>$model->id));
     				Yii::app()->user->setFlash('success', "..La salida para reserva  se ha anulado!");
     						$this->render('update',array(
     							'model'=>$model,
     							'movimiento'=> $movimiento,
     							));
     			      } else {
     			      	//revertimos la transaccion
     			      	throw new CHttpException(500,'No se pudo grabar el documento vale');
     			      }
     		} else {
     			$movimiento='Confirmaanulacargainicial';
     				$this->render('update',array(
     			'model'=>$model,
     			'movimiento'=> $movimiento,
     		));
     			      }		*/
 }