function _moduleContent(&$smarty, $module_name) { //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoOtrosdatos.class.php"; //include file language agree to elastix configuration //if file language not exists, then include language by default (en) $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; //conexion resource $pDB = new paloDB($arrConf['dsn_conn_database']); //actions $action = getAction(); $content = ""; $filter_field = getParameter("filter_field"); $filter_value = getParameter("filter_value"); if (isset($_POST['ingresar']) && $_POST['ingresar'] == "Ingresar") { $action = "view_form"; } if (isset($_POST['save_edit']) && $_POST['save_edit'] == "Editar") { actualizarDatoComplementario($_POST['tabla'], $_POST['id'], $_POST['dato1'], $_POST['dato2'], $pDB); $_POST['filter_field'] = $_POST['tabla']; } switch ($action) { case "view_edit": case "view_form": // no necesariamente sólo viene por $_POST, tambien viene por $_GET if ($filter_field == "cliente_telefono" || $filter_field == "cliente_direccion" || $filter_field == "cliente_adicional") { $content = viewFormIngresodeotrosdatos($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } break; case "delete": if (isset($_GET['filter_field']) && isset($_GET['id'])) { desactivarDatoComplementario($filter_field, $_GET['id'], $pDB); // $_GET['filter_field'] = $_GET['table']; // para no borrar el listado } case "save_new": if (isset($_POST['dato1']) && $_POST['dato1'] != "") { guardarDatoComplementario($_POST['tabla'], $_POST['dato1'], $_POST['dato2'], $pDB); $_GET['filter_field'] = $_POST['tabla']; // para no borrar el listado } default: $content = reportOtrosdatos($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; } return $content; }
function saveNewIngresodeotrosdatos($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pIngresodeotrosdatos = new paloSantoIngresodeotrosdatos($pDB); $arrFormIngresodeotrosdatos = createFieldForm(); $oForm = new paloForm($smarty, $arrFormIngresodeotrosdatos); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } $smarty->assign("mb_message", $strErrorMsg); $content = viewFormIngresodeotrosdatos($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } else { //NO ERROR, HERE IMPLEMENTATION OF SAVE $content = "Code to save yet undefined."; } return $content; }