Example #1
0
 function __construct($table, $id = 0)
 {
     $fields = $id == 0 ? aimsys::_getinsertfields($table) : aimsys::_getupdatefields($table);
     $this->_elms = (object) array();
     $ii = 0;
     foreach ($fields as $f) {
         $pri = aimsys::_getprimary($table);
         if ($id > 0) {
             $select = "SELECT * FROM `{$table}` WHERE `{$pri}` = {$id}";
             $result = new db($select);
             $row = $result[0];
         }
         $p = new params($table, $f);
         // Setup the parameters for the input field. params('table','col')
         $p->input_value = $row[$f];
         // Set the value of the field, if edit.
         $p->update_allowed = $id == 0 ? 'true' : $p->update_allowed;
         $parent = $p->input_type;
         // Mine the type of input from the param set
         $i = new $parent($p);
         // Create new instance of input type
         $this->_elms->{$ii}->label = $i->_label->get();
         // Get the label
         $this->_elms->{$ii}->input = $i->get();
         // Get the element
         $this->_elms->{$ii}->params = $i;
         // Get the element params
         $ii++;
     }
     $p = new params();
     $p->input_name = 'frm_name';
     $p->input_type = 'hidden';
     $p->input_value = $this->name;
     $i = new hidden($p);
     $this->_elms->{$ii}->input = $i->get();
     // Get the element
     $this->_elms->{$ii}->params = $i;
     // Get the element params
     $ii++;
     $p = new params();
     $p->input_name = 'table_name';
     $p->input_type = 'hidden';
     $p->input_value = $table;
     $i = new hidden($p);
     $this->_elms->{$ii}->input = $i->get();
     // Get the element
     $this->_elms->{$ii}->params = $i;
     // Get the element params
     $ii++;
 }
Example #2
0
if ($__POST["idCurrent"] != "") {
    // indique la modification d'un élément
    $idCurrent = $__POST["idCurrent"];
}
$formMaj = new formMaj();
$formMaj->tables = $myTable;
$formMaj->fields = "*";
$formMaj->where = "id=:id";
$formMaj->whereValue["id"] = array($idCurrent, PDO::PARAM_INT);
$formMaj->multiLang = true;
$formMaj->clause_where();
// si validation du formulaire
if ($__POST["actionForm"] != "") {
    $formMaj->set_datas();
}
$newfield = new hidden();
$newfield->field = "id_parent";
$newfield->multiLang = false;
$newfield->defaultValue = $idParent;
$newfield->add();
$newfield = new input();
$newfield->field = "titre";
$newfield->multiLang = true;
$newfield->label = "Titre (si différent du type)";
$newfield->add();
// on charge tout les types de texte
$obj_article = new article("type_texte_itineraire");
$obj_article->fields = "id,titre";
$result = $obj_article->query();
$tab_type_texte_itineraire = array();
foreach ($result as $row) {
Example #3
0
 public function add($param = "")
 {
     global $myAdmin;
     global $formMaj;
     global $datas_lang;
     global $smarty;
     global $thisSite;
     parent::add();
     if ($this->insideForm == false) {
         $this->fileRequired = true;
         $this->legendeEnabled = true;
     }
     if ($this->insideForm == true) {
         $prefixe_field = $this->field . "__";
         $mySelect = new mySelect(__FILE__);
         $mySelect->tables = $thisSite->PREFIXE_TBL_GEN . "medias";
         $mySelect->fields = "*";
         $mySelect->orderby = "id DESC";
         // pour prendre le premier élément
         $mySelect->where = "field_media=:field_media AND id_parent=:id_parent";
         $mySelect->whereValue["field_media"] = array($this->field, PDO::PARAM_STR);
         //$formMaj->tables . "." .
         $id_parent = $formMaj->datasForm[$myAdmin->LANG_DATAS]["id"];
         if ($id_parent == "") {
             $id_parent = $formMaj->datasForm[""]["id"];
         }
         $mySelect->whereValue["id_parent"] = array($id_parent, PDO::PARAM_INT);
         $resultmySelect = $mySelect->query();
         foreach ($resultmySelect as $rowS) {
             $lg = $rowS["lg"];
             $value_fichier_media[$lg] = $rowS["fichier_media"];
             $value_titre_media[$lg] = $rowS["titre_media"];
             if ($lg == $myAdmin->LANG_DEF) {
                 // pour les données monolangue
                 $value_idMedia = $rowS["id"];
                 $value_fichier_media[""] = $rowS["fichier_media"];
                 $value_titre_media[""] = $rowS["titre_media"];
             }
         }
     } else {
         $prefixe_field = "";
     }
     $newfield = new file();
     $newfield->field = $prefixe_field . "fichier_media";
     $newfield->multiLang = $this->multiLangType;
     if ($this->insideForm == true) {
         $newfield->label = $this->label;
     } else {
         $newfield->label = $datas_lang["fichier_media"];
     }
     $newfield->value = $value_fichier_media;
     $newfield->startFolder = $this->startFolder;
     $newfield->tooltip = $this->tooltip;
     $newfield->addClass = $this->addClass;
     $newfield->extensionsAuthorized = "";
     if ($this->extensionsAuthorized != "") {
         $newfield->extensionsAuthorized = $this->extensionsAuthorized;
     }
     $newfield->multi = $this->multi;
     $newfield->upload = $this->upload;
     $newfield->uploadDirect = $this->uploadDirect;
     $newfield->widthLabel = 2;
     $newfield->widthField = 9;
     $newfield->placeholder = $this->placeholder;
     $result = $newfield->add();
     $field_fichier_media = $result;
     if ($this->fileRequired == true) {
         $newfield->rule("required", true);
     }
     // champ Titre: légende de l'image, du fichier ou du lien
     if ($this->legendeEnabled == true) {
         $newfield = new input();
         $newfield->field = $prefixe_field . "titre_media";
         $newfield->multiLang = true;
         $newfield->value = $value_titre_media;
         $newfield->label = $datas_lang["legende"];
         $newfield->tooltip = $datas_lang["tooltipsLegende"];
         $newfield->widthLabel = 2;
         $newfield->widthField = 9;
         $result = $newfield->add();
         $field_titre_media = $result;
     }
     $smarty->assign('field_fichier_media', $field_fichier_media);
     $smarty->assign('field_titre_media', $field_titre_media);
     if ($this->insideForm == true) {
         $newfield = new hidden();
         $newfield->field = "fieldMedia__" . $this->field;
         $newfield->multiLang = false;
         $newfield->value = serialize(array("type" => $this->type, "field_media" => $this->field, "idMedia" => $value_idMedia));
         $result = $newfield->add();
         $smarty->assign('fieldMediaField', $result);
     }
     $smarty->assign('this', $this);
     $data = $smarty->fetch($this->pathTemplate . 'inc/fields/class.mediaFile.tpl');
     if ($this->insideForm == true) {
         $this->smartAssign($this->field, $data);
     } else {
         $this->smartAssign("media", $data);
     }
     return $data;
 }
 public function initialize($obj = null, $options = array())
 {
     $detalhes = unserialize($this->ecommerce_options->produto_detalhe_options);
     foreach ($detalhes as $key => $value) {
         $chave = $key;
         $chave = new Select("detalhes[{$value['label']}][]", $value['referencia']::find(array('order' => 'nome ASC')), array('using' => array('nome', 'nome')));
         $chave->setLabel($value['label']);
         $chave->setAttribute('class', 'form-control ' . $value['label']);
         if (!is_null($obj)) {
             $chave->setDefault($obj->{$value}['label']);
         }
         $this->add($chave);
     }
     #Input Valor
     $valor = new Text("detalhes[valor][]");
     $valor->setLabel("valor");
     $valor->setAttribute('class', 'form-control money');
     if (!is_null($obj)) {
         $valor->setDefault($obj->valor);
     }
     $this->add($valor);
     #Input desconto
     $desconto = new Text("detalhes[desconto][]");
     $desconto->setLabel("desconto");
     $desconto->setAttribute('class', 'form-control money');
     if (!is_null($obj)) {
         $desconto->setDefault($obj->desconto);
     }
     $this->add($desconto);
     #Input Estoque
     $estoque = new Numeric("detalhes[estoque][]");
     $estoque->setLabel("estoque");
     $estoque->setAttribute('class', 'form-control');
     $this->add($estoque);
     if (!is_null($obj)) {
         $estoque->setDefault($obj->estoque);
     }
     if ($this->ecommerce_options->produto_cubagem_detalhe == '1') {
         $peso = new Numeric("detalhes[peso][]");
         $peso->setLabel("peso");
         $peso->setAttribute('class', 'form-control');
         if (!is_null($obj)) {
             $peso->setDefault($obj->peso);
         }
         $this->add($peso);
         $altura = new Numeric("detalhes[altura][]");
         $altura->setLabel("altura");
         $altura->setAttribute('class', 'form-control');
         $this->add($altura);
         if (!is_null($obj)) {
             $altura->setDefault($obj->altura);
         }
         $largura = new Numeric("detalhes[largura][]");
         $largura->setLabel("largura");
         $largura->setAttribute('class', 'form-control');
         $this->add($largura);
         if (!is_null($obj)) {
             $largura->setDefault($obj->largura);
         }
         $comprimento = new Numeric("detalhes[comprimento][]");
         $comprimento->setLabel("comprimento");
         $comprimento->setAttribute('class', 'form-control');
         $this->add($comprimento);
         if (!is_null($obj)) {
             $comprimento->setDefault($obj->comprimento);
         }
     }
     if (!is_null($obj)) {
         $detalhe_id = new hidden("detalhes[detalhe_id][]");
         $detalhe_id->setAttribute('class', 'form-control detalhe_id dynamicId');
         $detalhe_id->setDefault($obj->detalhe_id);
         $this->add($detalhe_id);
     }
 }