Example #1
0
<?php

include_once realpath(dirname(__FILE__) . '/Medicamento.class.php');
$Medicamento = new Medicamento();
switch ($_REQUEST['a']) {
    case 'listar':
        permisos(CONFIGURACION, 'r');
        $Medicamento->listar();
        break;
    case 'ingresarForm':
        permisos(CONFIGURACION, 'w');
        $Medicamento->ingresarForm();
        break;
    case 'ingresar':
        permisos(CONFIGURACION, 'w');
        $Medicamento->ingresar();
        break;
    case 'actualizarForm':
        permisos(CONFIGURACION, 'u');
        $Medicamento->actualizarForm();
        break;
    case 'actualizar':
        permisos(CONFIGURACION, 'u');
        $Medicamento->actualizarDatos();
        break;
    case 'eliminar':
        permisos(CONFIGURACION, 'd');
        $Medicamento->borrar($_REQUEST['id']);
        break;
}
Example #2
0
<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'condicionmedicamento-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Campos con <span class="required">*</span> son Obligatorios.</p>

	<?php 
echo $form->errorSummary($model);
?>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'Medicamento_idMedicamento');
?>
		<?php 
echo $form->dropDownList($model, 'Medicamento_idMedicamento', CHtml::listData(Medicamento::model()->findAll(), 'idMedicamento', 'Nombre'));
?>
		<?php 
echo $form->error($model, 'Medicamento_idMedicamento');
?>
	</div>
	
	<div class="row">
		<?php 
echo $form->labelEx($model, 'Dosis');
?>
		<?php 
echo $form->textField($model, 'Dosis', array('size' => 15, 'maxlength' => 15));
?>
		<?php 
echo $form->error($model, 'Dosis');
Example #3
0
 /**
  * indicaciĆ³n completa
  * @return string
  */
 public function indicacion()
 {
     return $this->medicamento->nombre() . ': Tomar ' . $this->dosis . $this->periodo;
 }
Example #4
0
 /**
  * Remove medicamentos
  *
  * @param \Medicamento $medicamentos
  */
 public function removeMedicamento(\Medicamento $medicamentos)
 {
     $medicamentos->setCategoria(null);
     $this->medicamentos->removeElement($medicamentos);
 }
Example #5
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Medicamento the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Medicamento::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #6
0
 $r = null;
 if ($app->request->headers->get('Content-Type') === $contentType['json'] || $app->request->headers->get('Content-Type') === $contentType['jsonapi']) {
     $validator['validator']->check($data, $schema);
     if ($validator['validator']->isValid()) {
         $farmacia = json_decode($app->request->getBody(), true);
         $nome = $farmacia['nome'];
         $descricao = $farmacia['descricao'];
         $f = $em->find('Farmacia', $fid);
         $s = $em->find('Stock', $sid);
         $c = $em->find('Categoria', $cid);
         if ($f !== null && $s !== null && $c !== null) {
             if ($f->getStockes()->contains($s) && $s->getCategorias()->contains($c)) {
                 $em->getConnection()->beginTransaction();
                 $medicamentoCriado = true;
                 try {
                     $m = new Medicamento();
                     $m->setNome($nome);
                     $m->setDescricao($descricao);
                     $m->setDataDeCriacao(new DateTime('NOW'));
                     $m->setDataDeActualizacao(new DateTime('NOW'));
                     $m->setPreco(0);
                     $m->setQuantidade(0);
                     $c->addMedicamento($m);
                     $em->persist($c);
                     $em->flush();
                     $em->getConnection()->commit();
                 } catch (Exception $e) {
                     $em->getConnection()->rollback();
                     $medicamentoCriado = false;
                 }
                 if ($medicamentoCriado) {