Пример #1
0
 /**
  * Agregar una restricción para limitar los resultados a ser recuperados
  * @param Restrictions $restrictions
  * @return Criteria $this
  */
 public function add(Restrictions $restrictions)
 {
     if (!$this->flagCreateCtriteria) {
         throw new Exception('Necesita inicializar el criteria');
     }
     if (!is_array($this->array_restrictions)) {
         $this->array_restrictions = array("1" => $restrictions->getExpr());
     } else {
         array_push($this->array_restrictions, $restrictions->getExpr());
     }
     $this->SQL = MySQL_DB::instance()->DBSQLSelect($this->table, null, $this->array_restrictions, $this->array_order, $this->type_order, true);
     return $this;
 }
 /**
  * @param form_persistentdocument_form $form
  * @return Integer
  */
 public function fileForForm($form)
 {
     $count = 0;
     $responses = $this->createQuery()->add(Restrictions::eq('parentForm.id', $form->getId()))->add(Restrictions::published())->find();
     foreach ($responses as $response) {
         $this->file($response->getId());
         $count++;
     }
     return $count;
 }
 public function _execute($context, $request)
 {
     $form = $request->getAttribute('form');
     $this->setAttribute('form', $form);
     $domDoc = new DOMDocument();
     $fieldNames = array('creationdate' => f_Locale::translate('&modules.form.bo.actions.SendDate;'));
     $query = f_persistentdocument_PersistentProvider::getInstance()->createQuery('modules_form/response')->add(Restrictions::eq('parentForm.id', $form->getId()))->addOrder(Order::desc('document_creationdate'));
     if ($request->getAttribute('all') != 'all') {
         $query->add(Restrictions::published());
     }
     $responses = $query->find();
     $responsesAttribute = array();
     foreach ($responses as $response) {
         $domDoc->loadXML($response->getContents());
         $xpath = new DOMXPath($domDoc);
         $fieldList = $xpath->query('/response/field');
         $fields = array('creationdate' => $response->getUICreationdate());
         for ($i = 0; $i < $fieldList->length; $i++) {
             $fieldNode = $fieldList->item($i);
             $fieldName = $fieldNode->getAttribute('name');
             $fieldLabel = $fieldNode->getAttribute('label');
             $fieldType = $fieldNode->getAttribute('type');
             $fieldValue = $fieldNode->nodeValue;
             if ($fieldType == 'file') {
                 $fieldValue = intval($fieldNode->nodeValue);
                 if ($fieldValue > 0) {
                     $fieldValue = MediaHelper::getUrl($fieldValue);
                 } else {
                     $fieldValue = '';
                 }
             } else {
                 if ($fieldType == 'list' && $fieldNode->hasAttribute('mailValue')) {
                     $fieldValue = $fieldNode->getAttribute('mailValue');
                 }
             }
             if (!isset($fieldNames[$fieldName])) {
                 $fieldNames[$fieldName] = $fieldLabel;
             }
             $fields[$fieldName] = $fieldValue;
         }
         $responsesAttribute[] = $fields;
     }
     $fileName = "export_formulaire_" . f_util_FileUtils::cleanFilename($form->getLabel()) . '_' . date('Ymd_His') . '.csv';
     $options = new f_util_CSVUtils_export_options();
     $options->separator = ";";
     $csv = f_util_CSVUtils::export($fieldNames, $responsesAttribute, $options);
     header("Content-type: text/comma-separated-values");
     header('Content-length: ' . strlen($csv));
     header('Content-disposition: attachment; filename="' . $fileName . '"');
     echo $csv;
     exit;
 }
 /**
  * @param f_peristentdocument_PersistentDocument $conditionOn
  * @return integer[]
  */
 private function getExcludeIds($conditionOn)
 {
     $excludeIds = array();
     if ($conditionOn instanceof form_persistentdocument_field) {
         $excludeIds = array($conditionOn->getId());
     } else {
         if ($conditionOn instanceof form_persistentdocument_group) {
             $query = form_FieldService::getInstance()->createQuery();
             $query->add(Restrictions::descendentOf($conditionOn->getId()));
             $query->setProjection(Projections::property('id'));
             $excludeIds = $query->findColumn('id');
         }
     }
     return $excludeIds;
 }
 public function _execute($context, $request)
 {
     $this->setTemplateName('Form-Responses', K::HTML);
     $form = $request->getAttribute('form');
     $this->setAttribute('form', $form);
     $query = form_ResponseService::getInstance()->createQuery()->add(Restrictions::eq('parentForm', $form))->addOrder(Order::desc('document_creationdate'));
     if ($request->getAttribute('all') != 'all') {
         $query->add(Restrictions::published());
     }
     $responses = $query->find();
     $this->setAttribute('responsesCount', count($responses));
     $responsesInfos = array();
     foreach ($responses as $response) {
         $responsesInfos[] = $response->getResponseInfos();
     }
     $this->setAttribute('responses', $responsesInfos);
 }
Пример #6
0
            $criteria->find($alumnoGuardar);
            $alumnoGuardar->lista = $i++;
            $criteria->merge($alumnoGuardar);
        }
        moveLocationFast("UTP-listaCurso.php?curso=" . $curso . "&exito=exito");
    }
}
$orden_alfabetico = false;
if (isset($_POST['buscar'])) {
    if ($_POST['buscar'] == "orden_alfabetico") {
        $smarty->assign("warning", "Para que la lista quede guardada debe presionar el botón guardar");
        $orden_alfabetico = true;
    }
}
$criteria->createCriteria($alumno);
$criteria->add(Restrictions::eq("curso", $curso));
if (!$orden_alfabetico) {
    $criteria->addOrder(Order::asc("lista"));
} else {
    $criteria->addOrder(Order::asc("apellidop, apellidom, nombres"));
}
$listAlumnos = $criteria->lista();
$smarty->assign("listAlumnos", $listAlumnos);
$smarty->assign("titulo_principal", mostrar_curso($curso, true));
$smarty->assign("title", "UTP: Modificar Cursos");
$smarty->assign("titulo_secundario", "Listado Alumnos");
$menu[] = array("img" => "", "url" => "modificar_cursos.php", "text" => "Volver", "title" => "Volver", "alt" => "Volver");
$menu[] = array("img" => "", "url" => "#", "text" => "Lista Alumnos", "title" => "Lista Alumnos", "alt" => "Lista Alumnos", "id" => "", "class" => "current_page_item");
$smarty->assign("menu", $menu);
$smarty->assign("file_content", "utp/UTP-listaCurso.tpl");
$smarty->display('layout/main.tpl');
Пример #7
0
 /**
  * Apply a "between" constraint to this property
  *
  * @param   var lo
  * @param   var hi
  * @return  rdbms.criterion.SimpleExpression
  */
 public function between($lo, $hi)
 {
     return Restrictions::between($this, $lo, $hi);
 }
Пример #8
0
 /**
  * Restricción: Entremedio de valores
  * <br> $valor_menor < $field < $valor_mayor
  * @param string $field
  * @param string $valor
  * @return string $stringRestriction
  */
 public static function between($field, $valor_menor, $valor_mayor)
 {
     $restrictions = Restrictions::instance();
     $restrictions->expr = Restrictions::gt($field, $valor_menor)->getExpr() . " AND " . Restrictions::lt($field, $valor_mayor)->getExpr();
     return $restrictions;
 }
 /**
  * @param form_persistentdocument_baseform $form
  * @param integer[] $excludeIds
  */
 public function getValidActivationFields($form, $excludeIds = array())
 {
     $query = form_FieldService::getInstance()->createQuery();
     $query->add(Restrictions::descendentOf($form->getId()));
     if (f_util_ArrayUtils::isNotEmpty($excludeIds)) {
         $query->add(Restrictions::notin('id', $excludeIds));
     }
     $validFields = array();
     foreach ($query->find() as $field) {
         if ($field instanceof form_persistentdocument_boolean || $field instanceof form_persistentdocument_list) {
             $validFields[] = $field;
         }
     }
     return $validFields;
 }
Пример #10
0
    $bloques_horario = $class_horario->generarBloques();
    $smarty->assign("bloques_horario", $bloques_horario);
    $horario->FK_personal_pers_ID = $personal->pers_ID;
    $horario->hrs_anio = $_SESSION['base_datos']->anio;
    $criteria->find($horario);
    $valores_horario['lunes'] = explode(";", $horario->hrs_lunes);
    $valores_horario['martes'] = explode(";", $horario->hrs_martes);
    $valores_horario['miercoles'] = explode(";", $horario->hrs_miercoles);
    $valores_horario['jueves'] = explode(";", $horario->hrs_jueves);
    $valores_horario['viernes'] = explode(";", $horario->hrs_viernes);
    $valores_horario['sabado'] = explode(";", $horario->hrs_sabado);
    $smarty->assign("valores_horario", $valores_horario);
    $criteria->createCriteria($observacion);
    $criteria->addOrder(Order::desc("obs_ID"));
    $criteria->add(Restrictions::eq("FK_persona_per_ID", $persona->per_ID));
    $criteria->add(Restrictions::eq("obs_anio", $_SESSION['base_datos']->anio));
    $listObservaciones = $criteria->lista();
    $smarty->assign("listObservaciones", $listObservaciones);
}
if (isset($_GET['exito']) && !isset($_POST['guardar'])) {
    if ($_GET['exito'] == "exito") {
        $smarty->assign("exito", "La información se ha guardado exitosamente");
    }
}
if (isset($_POST['guardar']) && postForm($_POST['postID'])) {
    if ($_POST['guardar'] == "Enviar Foto") {
        if ($persona->per_ID) {
            subirFotoAlumno($per_ID);
        }
    }
    if ($_POST['guardar'] == "guardar_persona") {
 /**
  * @param form_persistentdocument_form
  * @deprecated with no replacement
  */
 public function getPreviewAttributes($document)
 {
     $attributes = array();
     $query = f_persistentdocument_PersistentProvider::getInstance()->createQuery('modules_form/field');
     $query->add(Restrictions::descendentOf($document->getId()));
     $fields = $query->find();
     $attributes['fieldsCount'] = count($fields);
     $attributes['responsesCount'] = $document->getResponseCount();
     return $attributes;
 }
Пример #12
0
 public function restrictionsFactory()
 {
     $job_id = Job::column('job_id');
     $c = new Criteria(Restrictions::anyOf(Restrictions::not($job_id->in(array(1, 2, 3))), Restrictions::allOf(Job::column('title')->like('Hello%'), Job::column('valid_from')->greaterThan(new Date('2006-01-01'))), Restrictions::allOf(Restrictions::like('title', 'Hello%'), Restrictions::greaterThan('valid_from', new Date('2006-01-01'))), $job_id->between(1, 5)));
     $this->assertSql('where (not (job_id in (1, 2, 3))' . ' or (title like "Hello%" and valid_from > "2006-01-01 12:00AM")' . ' or (title like "Hello%" and valid_from > "2006-01-01 12:00AM")' . ' or job_id between 1 and 5)', $c);
 }
Пример #13
0
 function restrictionTest()
 {
     $this->assertSQL('where job_id = ceil(asin(sin(0.125)))', 'where job_id = ceiling(asin(sin(0.125)))', 'where job_id = ceil(asin(sin(0.125)))', 'where job_id = php(\'ceil\', php(\'asin\', php(\'sin\', 0.125)))', create(new Criteria())->add(Restrictions::equal('job_id', SQLFunctions::ceil(SQLFunctions::asin(SQLFunctions::sin(0.125))))));
     $this->assertSQL('where job_id = ceil(asin(sin(0.125)))', 'where job_id = ceiling(asin(sin(0.125)))', 'where job_id = ceil(asin(sin(0.125)))', 'where job_id = php(\'ceil\', php(\'asin\', php(\'sin\', 0.125)))', create(new Criteria())->add(Restrictions::equal(Job::column('job_id'), SQLFunctions::ceil(SQLFunctions::asin(SQLFunctions::sin(0.125))))));
 }
Пример #14
0
     mkdir(CRITERIA_PATH_RELATIVE . "generation", 0755);
     echo "<hr>Entitades en la carpeta generation:<hr>";
     $criteriaDBDefault = $_POST["database"];
     $criteriaGenerate = new CriteriaGenerate($criteriaDBDefault);
     $criteriaGenerate->generateEntity();
     listar_directorios_ruta(CRITERIA_PATH_RELATIVE . "generation");
     break;
 case "CARGAR_PRUEBAS":
     echo "Cargando Pruebas";
     require_once 'generation/EntityBecas.php';
     //            require_once 'generation/EntityArancel.php';
     $criteria = new Criteria();
     $becas = new EntityBecas();
     $criteria->createCriteria($becas);
     $criteria->add(Restrictions::eq("beca_anio", "2011"));
     $criteria->add(Restrictions::between("beca_ID", 4, 9));
     $criteria->addOrder(Order::desc("beca_ID"));
     //$criteria->
     dprCriteria($criteria->getSQL());
     $lol = $criteria->lista();
     dprCriteria($lol);
     //$criteria->add($restrictions);
     //            $filial = new EntityCCA_FILIAL();
     //            $filial->ID_FILIAL = 1;
     //            $criteria->find($filial);
     //            dpr($filial);
     //            $filial->APLICACION_ACTUALIZACION = "PruebMerg2";
     //            $criteria->merge($filial);
     //            $filial->ID_FILIAL = null;
     //            $filial->APLICACION_ACTUALIZACION = "Persist";
     //            $criteria->persist($filial);
Пример #15
0
 /**
  * Restricción: Entremedio de valores
  * <br> $valor_menor < $field < $valor_mayor
  * @param <string> $field
  * @param <string> $valor
  * @return <string> $stringRestriction
  */
 public static function between($field, $valor_menor, $valor_mayor)
 {
     return Restrictions::gt($field, $valor_menor) . " AND " . Restrictions::lt($field, $valor_mayor);
 }