';
$html .= '
';
$html .= '
';
$html .= '
';
$this->formulario .= $html;
return $this;
}
public function mostrarCategorias($name, $prefijo, $idParentCategoria = 2) {
$sql = ' SELECT '
. ' c.id_category, c.id_parent, cl.name, s.id_category AS checked, s.margen '
. ' FROM '
. ' ' . _DB_PREFIX_ . 'category AS c '
. ' INNER JOIN ' . _DB_PREFIX_ . 'category_lang AS cl '
. ' ON '
. ' cl.id_category = c.id_category '
. ' AND cl.id_lang = ' . $this->idLang . ''
. ' AND c.id_shop_default = cl.id_shop '
. ' AND c.id_shop_default = ' . $this->idShop . ''
. ' LEFT JOIN ' . _DB_PREFIX_ . $prefijo . 'categorias AS s '
. ' ON s.id_category = c.id_category '
. ' WHERE '
. ' c.id_parent = ' . $idParentCategoria . ' '
. ' ORDER BY '
. ' c.id_parent, c.id_category ';
$categorias = Db::getInstance()->executeS($sql);
$html = '
';
$html .= '
';
$html .= '';
$this->formulario .= $html;
return $this;
}
private function getHijosTable($categoria, &$html, &$num, $prefijo) {
$numInterno = $num;
$sqlHijos = ' SELECT '
. ' c.id_category, c.id_parent, cl.name, s.id_category AS checked, s.margen '
. ' FROM '
. ' ' . _DB_PREFIX_ . 'category AS c '
. ' INNER JOIN ' . _DB_PREFIX_ . 'category_lang AS cl '
. ' ON '
. ' cl.id_category = c.id_category '
. ' AND cl.id_lang = ' . $this->idLang . ' '
. ' AND c.id_shop_default = cl.id_shop '
. ' AND c.id_shop_default = ' . $this->idShop . ' '
. ' LEFT JOIN ' . _DB_PREFIX_ . $prefijo . 'categorias AS s '
. ' ON s.id_category = c.id_category '
. ' WHERE '
. ' c.id_parent=' . $categoria['id_category'];
$categoriasHijos = Db::getInstance()->executeS($sqlHijos);
$num++;
foreach ($categoriasHijos AS $categoriaHijo) {
$checked = "";
$porcentaje = "";
if (!empty($categoriaHijo['checked']) && $categoriaHijo['checked'] != null) {
$checked = ' checked="checked"';
$porcentaje = $categoriaHijo['margen'];
}
$numClase = $num;
$html .= '
';
$html .= '| ' . str_repeat(" ", $num * 2) . $categoriaHijo['name'] . ' | ';
$html .= ' | ';
$html .= ' | ';
$html .= '
';
$this->getHijos($categoriaHijo, $html, $num);
}
$num = $numInterno;
}
/**
*
* @param string $name
* @param string $text
* @param int $defaultValue
* @param string $title
* @param boolean $active
* @param boolean $chosen
* @return $this
*/
public function createSelectCategory($name, $text, $defaultValue, $title = '', $active = true, $chosen = false) {
$categories = Category::getHomeCategories($this->idLang, $active);
$html = '';
$html .= '
';
if ($chosen) {
$html .= '';
}
$this->formulario .= $html;
return $this;
}
private function getHijos($id_parent, $defaultValue, &$html, &$num, $active) {
$numInterno = $num;
$categories = Category::getChildren($id_parent, $this->idLang, $active);
if (!$categories) {
return;
}
$num++;
foreach ($categories AS $category) {
$selected = '';
if ($category['id_category'] == $defaultValue) {
$selected = ' selected="selected"';
}
$html .= '
' . htmlspecialchars(trim($category['name'])) . '';
$this->getHijos($category['id_category'], $defaultValue, $html, $num, $active);
}
$num = $numInterno;
return true;
}
/**
* Crea un upload File.
* @param string $name Nombre del boton
* @param string $text Texto informativo
* @param string $title Titulo
* @return $this
*/
public function createFormUploadFile($name, $text, $title = '') {
$html = '';
$html .= '
';
$this->formulario .= $html;
return $this;
}
/**
* Crea una tabla dinamica.
* @param string $name Identificador de la tabla.
* @param string $table Nombre de la tabla en la base de datos.
* @param string[] $campos Nombres de los campos en base de datos.
* @param string[] $camposBusqueda Nombres de los campos en base de datos para las busquedas.
* @param string $url Ruta base.
* @param string $serverfile Archivo de destino en el servidor.
* @param string $contenidoCabecera Los "tr" para la cabecera.
* @param string[] $codigoFormateadores [id del formateador => Contenido de la funcion formateadora, recibe los parametros column y row].
* @param string $codigoEventoLoad Contenido de la funcion del evento load. La tabla viene en la variable grid. Tambien se dispone de e.
* @return $this
*/
function createTableAjax($name, $table, $campos, $camposBusqueda, $url, $serverfile, $contenidoCabecera, $codigoFormateadores = array(), $codigoEventoLoad = '') {
$html = '
';
$this->formulario .= $html;
return $this;
}
private function addExtras($extras) {
$html = '';
if ($extras && is_array($extras)) {
foreach ($extras AS $indice => $valor) {
$html .= $indice . '="' . $valor . '"';
}
}
return $html;
}
public function __toString() {
return $this->renderForm(true);
}
public function createCheckBoxManufacturer($name, $defaultValue) {
$manufacturers = Manufacturer::getManufacturers();
$html = '';
$numElementos = count($manufacturers);
$elementos = ceil($numElementos / 3);
$intercambio = array_flip($defaultValue);
$i = 0;
$html .= '
';
$html .= '
';
$this->formulario .= $html;
return $this;
}
/**
*
* @param int $id_lang
* @param string $name
* @param string $text
* @param array $values
* @param string $title
* @return $this
*/
public function createOptionStatuses($id_lang, $name, $text, $values, $title = '') {
$status = OrderState::getOrderStates($id_lang);
$html .= '
';
$this->formulario .= $html;
return $this;
}
/**
*
* @param string $name
* @param string $text
* @param int $defaultValue
* @param string $title
* @return $this
*/
public function createSelectStatuses($idLang, $name, $text, $defaultValue, $title = '') {
$status = OrderState::getOrderStates($idLang);
$html = '
';
$this->formulario .= $html;
return $this;
}
/**
*
* @param string $name
* @param string $text
* @param int $defaultValue
* @param string $title
* @return $this
*/
public function createSelectFeatures($idLang, $name, $text, $defaultValue, $title = '') {
$features = Feature::getFeatures($idLang);
$html = '
';
$this->formulario .= $html;
return $this;
}
/**
*
* @param string $name
* @param string $text
* @param int $defaultValue
* @param string $title
* @return $this
*/
public function createSelectFeaturesValues($idLang, $name, $text, $defaultValue, $value, $title = '') {
$features = FeatureValueCore::getFeatureValuesWithLang($idLang, $value);
$html .= '
';
$this->formulario .= $html;
return $this;
}
/**
* Genera un select a partir de un array asociativo.
* @param string $name
* @param string $text
* @param array $datos
* @param string $claveId
* @param string $claveValores
* @param mixed $selectedValue
* @param string $title
* @param array $extras
* @return $this
*/
public function createFormSelectFromArray($name, $text, $datos, $claveId, $claveValores, $selectedValue, $title = '', $extras = null) {
$datosFormateados = array();
foreach ($datos as $dato) {
$datosFormateados[$dato[$claveId]] = $dato[$claveValores];
}
return $this->createFormSelect($name, $text, $datosFormateados, $selectedValue, $title, $extras);
}
}