/** * Método que valida que el dato sea un RUT válido * @param data Dato que se quiere validar * @return =true si es un RUT válido * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) * @version 2016-08-28 */ public static function check_rut($data) { if (!class_exists('\\sowerphp\\app\\Utility_Rut')) { return false; } return \sowerphp\app\Utility_Rut::check($data); }
/** * Método para generar página de configuración del módulo y procesar el * formulario al guardar los cambios * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) * @version 2016-01-30 */ public function getContent() { $output = null; if (Tools::isSubmit('submit' . $this->name)) { // verificar que se hayan pasado los datos mínimos $error = false; $config = []; foreach ($this->defaultConfig as $key => $value) { $valor = Tools::getValue($key); if (!$valor || empty($valor)) { $output .= $this->displayError($this->l('Debe especificar ' . $key)); $error = true; break; } else { $config[$key] = $valor; } } if ($config['LIBREDTE_CONTRIBUYENTE']) { $rut = \sowerphp\app\Utility_Rut::check($config['LIBREDTE_CONTRIBUYENTE']); if (!$rut) { $output .= $this->displayError($this->l('RUT del contribuyente es incorrecto')); $error = true; } else { $config['LIBREDTE_CONTRIBUYENTE'] = $rut; } } if (!$error) { foreach ($config as $key => $value) { Configuration::updateValue($key, $value); } $output .= $this->displayConfirmation($this->l('Configuración actualizada')); } } return $output . $this->displayForm() . $this->footer(); }