{	
	  var searchStr=document.getElementById('cuenta_id').value; 
	  location.href = '<?php 
        echo $clearURL;
        ?>
' + '&'+'cuenta_id=' + searchStr; 
	}
	</script>  <?php 
        break;
    case "_sample_vta_p_facturas":
        $url = new TableEditor_URL();
        $url->removeQueryString('folio_fiscal');
        $nuevoURL = $url->getURL(true);
        $url_detalle = new TableEditor_URL();
        $url_detalle->removeQueryString('table');
        $url_detalle->addQueryString('table', "_sample_vta_p_facturas_detalle");
        $nuevoURL_detalle = $url_detalle->getURL(true);
        $TEMainList .= '<tr><td colspan=2>';
        $TEMainList .= '<input name="folio_fiscal" type text>';
        $TEMainList .= '<input type=button value="Buscar factura" onclick=consulta()>';
        $TEMainList .= '</td><td colspan=2>';
        $TEMainList .= '<input name="buscar_en_partidas" type text>';
        $TEMainList .= '<input type=button value="Buscar en partidas" onclick=consulta_partidas()>';
        $TEMainList .= '</td></tr>';
        ?>
	<script language="javascript">
	function consulta()
	{	
	  var searchStr=document.getElementById('folio_fiscal').value; 
	  location.href = '<?php 
        echo $nuevoURL;
        }
    }
}
// Begin - 18 Nov 2008 - Titles Icons Bg
if (!empty($this->icons[$this->table]['icon'])) {
    foreach ($this->icons[$this->table]['icon'] as $icon => $html_icon) {
        $TEMainList .= '<th>&nbsp;</th>';
    }
}
// End - 18 Nov 2008 - Titles Icons Bg
$TEMainList .= '</tr>';
$url = new TableEditor_URL();
if (!empty($results)) {
    foreach ($results as $k => $row) {
        $url->removeQueryString('edit');
        $url->addQueryString('edit', $nonFilteredData[$k][$this->pk]);
        $UrlEdit = $url->getURL(true);
        $url->removeQueryString('edit');
        $url->addQueryString('view', $nonFilteredData[$k][$this->pk]);
        $UrlView = $url->getURL(true);
        $url->removeQueryString('view');
        $TEMainList .= '<tr onmouseover="this.className=\'TERowOver\';" ' . ($k % 2 == 1 ? 'class="TEaltRow" onmouseout="this.className=\'TEaltRow\';"' : 'class="TERow" onmouseout="this.className=\'TERow\';"') . ' ';
        if (TERowOnClickEdit == false || !$this->getConfig('allowEdit')) {
            $TEMainList .= ' onclick="TERowHighlight(this, this.firstChild.firstChild, \'' . ($k % 2 == 1 ? 'TEaltRow' : 'TERow') . '\');"';
        } elseif ($this->getConfig('allowEdit')) {
            $TEMainList .= 'style="cursor:pointer;"';
        }
        $TEMainList .= '>';
        if ($this->displayActionButtons()) {
            $TEMainList .= '<td class="TETdFieldsList">';
            $TEMainList .= '<input type="checkbox" name="rowSelector" id="rowSelector" onclick="TERowHighlight(this.parentNode.parentNode, this, \'' . ($k % 2 == 1 ? 'TEaltRow' : 'TERow') . '\');" ';
Example #3
0
 function displayHeader()
 {
     $headerfile = $this->getConfig('headerfile');
     if ($headerfile) {
         require $headerfile;
         return;
     }
     $table = $this->table;
     echo '<div class="TEmainbody" align="center">';
     if ($this->errors) {
         foreach ($this->errors as $e) {
             $aux_error = split(":", $e);
             if (strpos($aux_error[1], "Duplicate entry")) {
                 $aux_1 = split(" ", trim($aux_error[1]));
                 $NumberArray = count($aux_1);
                 $aux_2 = $aux_1[5];
                 $aux = TEgetPrimaryKeyOf($this->table);
                 $valor_duplicado = $aux_1[2];
                 $ElementDuplicate = (int) $aux_1[$NumberArray - 1];
                 $campo_duplicado = $aux[$ElementDuplicate];
                 $ArrayErrorTxt = split("'", trim($aux_error[1]));
                 $valor_duplicado = $ArrayErrorTxt[1];
                 if ($campo_duplicado != "") {
                     $RecordId = nombre_id($this->table, $campo_duplicado, str_replace("'", "", $valor_duplicado), $aux[1]);
                 }
                 $DuplicateErrorTxt = TEErrorDuplicateEntry . " ";
                 $url = new TableEditor_URL();
                 $url->removeQueryString('edit');
                 $url->removeQueryString('add');
                 $url->addQueryString('view', $RecordId);
                 $PopupUrl = $url->getURL(true);
                 $DuplicateErrorButton .= '<img src="' . TEImagesPath . 'TEActionView.gif" srcover="' . TEImagesPath . 'TEActionViewOver.gif" class="TEInputButton" ';
                 if (file_exists("" . TEditorPath . "TEPopupForm.php")) {
                     $DuplicateErrorButton .= 'onclick="TEWindowOpenPopup(\'' . $TEditorPath . 'TEPopupForm.php?table=' . $this->table . '&view=' . $RecordId . '&TEPopup=1\', \'DuplicateEntry\', \'500\', \'500\', \'0\', \'0\')" ';
                     $DuplicateErrorButton .= 'title="' . TEButtonAdd . '" alt="' . TEButtonAdd . '">&nbsp;';
                 } else {
                     $url = new TableEditor_URL();
                     $url->removeQueryString('edit');
                     $url->removeQueryString('add');
                     $url->addQueryString('view', $RecordId);
                     $PopupUrl = $url->getURL(true);
                     $DuplicateErrorButton .= 'onclick="TEWindowOpenPopup(\'' . $PopupUrl . '\', \'DuplicateEntry\', \'769\', \'400\', \'0\', \'1\')" title="' . TEButtonView . '" alt="' . TEButtonView . '">&nbsp;';
                 }
                 echo '<script language="javascript"> alert("ERROR: ' . $DuplicateErrorTxt . '\\n");</script><div class="TEditorError">ERROR: ' . $DuplicateErrorTxt . '<br>' . $DuplicateErrorButton . '</div>';
             } else {
                 echo '<script language="javascript"> alert("ERROR: ' . htmlspecialchars($e) . '"); </script><div class="TEditorError">ERROR: ' . htmlspecialchars($e) . '</div>';
             }
         }
     }
 }
     if (!$this->ArrayHiddenTables[$this->fields[$field]['LinkTable']] && $this->fields[$field]['LinkTable'] && ($edit || $add)) {
         echo '&nbsp;<img src="' . TEImagesPath . 'TEActionAdd.gif" srcover="' . TEImagesPath . 'TEActionAddOver.gif" class="TEInputButton" ';
         if (file_exists("" . TEditorPath . "TEPopupForm.php")) {
             //Url, Name, Width, Height, Align, Bars)
             echo 'onclick="TEWindowOpenPopup(\'' . $TEditorPath . 'TEPopupForm.php?table=' . $this->fields[$field]['LinkTable'] . '&add=1&TEPopup=1\', \'PopupAdd\', \'500\', \'500\', \'0\', \'0\')" ';
             echo 'title="' . TEButtonAdd . '" alt="' . TEButtonAdd . '">&nbsp;';
         } else {
             $UrlLinkAdd = new TableEditor_URL();
             if ($edit) {
                 $TxtRemove = 'edit';
             } elseif ($add == 1) {
                 $TxtRemove = 'add';
             }
             $UrlLinkAdd->removeQueryString($TxtRemove);
             $UrlLinkAdd->removeQueryString($table);
             $UrlLinkAdd->addQueryString('table', $this->fields[$field]['LinkTable']);
             $UrlLinkAdd->addQueryString('add', '1');
             $UrlLinkAdd = $UrlLinkAdd->getURL(true);
             echo 'onclick="window.open(\'' . $UrlLinkAdd . '\');" title="' . TEButtonAdd . '" alt="' . TEButtonAdd . '">&nbsp;';
         }
     }
     break;
 case 'file':
     if ($this->fields[$field]['DownloadPath'] && file_exists($this->fields[$field]['DownloadPath'])) {
         $TEDownloadPath = $this->fields[$field]['DownloadPath'];
     } else {
         $TEDownloadPath = TEDownloadsPath;
     }
     if ($add) {
         echo '<input type="file" name="' . $FieldName . '" id="' . $FieldName . '"' . $HtmlClass . ' style="width:300px;' . $HtmlStyle . '" maxlength="255"></td></tr><tr>';
         echo '<td><img src="' . TEImagesPath . 'space.gif" width="1" height="10" border="0" />';
     if (!$NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->ArrayHiddenTables[$NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->fields[$field]['LinkTable']] && $NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->fields[$field]['LinkTable'] && ($edit || $add)) {
         echo '&nbsp;<img src="' . TEImagesPath . 'TEActionAdd.gif" srcover="' . TEImagesPath . 'TEActionAddOver.gif" class="TEInputButton" ';
         if (file_exists("" . TEditorPath . "TEPopupForm.php")) {
             //Url, Name, Width, Height, Align, Bars)
             echo 'onclick="TEWindowOpenPopup(\'' . $TEditorPath . 'TEPopupForm.php?table=' . $NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->fields[$field]['LinkTable'] . '&add=1&TEPopup=1\', \'PopupAdd\', \'500\', \'500\', \'0\', \'0\')" ';
             echo 'title="' . TEButtonAdd . '" alt="' . TEButtonAdd . '">&nbsp;';
         } else {
             $UrlLinkAdd = new TableEditor_URL();
             if ($edit) {
                 $TxtRemove = 'edit';
             } elseif ($add == 1) {
                 $TxtRemove = 'add';
             }
             $UrlLinkAdd->removeQueryString($TxtRemove);
             $UrlLinkAdd->removeQueryString($table);
             $UrlLinkAdd->addQueryString('table', $NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->fields[$field]['LinkTable']);
             $UrlLinkAdd->addQueryString('add', '1');
             $UrlLinkAdd = $UrlLinkAdd->getURL(true);
             echo 'onclick="window.open(\'' . $UrlLinkAdd . '\');" title="' . TEButtonAdd . '" alt="' . TEButtonAdd . '">&nbsp;';
         }
     }
 } else {
     // para select deshabilitado
     $FieldValue_mostrar = "";
     if ($NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->fields[$field]['values']) {
         foreach ($NUEVO_editor_hijo[$TABLA_HIJO["TABLA_HIJO"]]->fields[$field]['values'] as $k => $v) {
             if ((string) $k === $value) {
                 //echo htmlspecialchars($k).'--'.htmlspecialchars($v)	;
                 $FieldValue = $k;
                 $FieldValue_mostrar = $v;
             }
 /**
  * Handles an add/edit page
  *
  * @param mixed $id Optional ID of row to edit
  */
 function handleAddEditCopy($id = null)
 {
     // Quote ID
     if (!is_null($id)) {
         $id = $this->dbQuote($id);
     }
     // Form posted back
     if (!empty($_POST)) {
         // Cancel button
         if ($_POST['action'] == 'Cancel') {
             $url = new TableEditor_URL();
             $url->removeQueryString('edit');
             $url->removeQueryString('add');
             $url->removeQueryString('copy');
             header('Location: ' . $url->getURL());
             exit;
         }
         // OK or Apply button
         $useFunctions = $this->getConfig('useFunctions');
         // Get fields which are "editable"
         foreach ($this->fields as $field => $value) {
             if (!empty($value['noEdit']) and !isset($value['default']) or $field == $this->pk and !$this->getConfig('allowPKEditing')) {
                 continue;
             }
             /**
              * Handle default values for none editable fields
              */
             if (!empty($value['noEdit']) and isset($value['default'])) {
                 $unQuoted[$field] = $value['default'];
                 $quoted[$field] = $this->dbQuote($value['default']);
                 continue;
             }
             /**
              * Handle functions
              */
             if ($useFunctions) {
                 $function = $_POST['function'][$field];
                 if (!empty($function) and !empty($this->config['functions'][$function])) {
                     $_POST[$field] = call_user_func($this->config['functions'][$function], $_POST[$field]);
                 }
             }
             /**
              * Handle required fields
              */
             if (!empty($this->fields[$field]['required']) and ($_POST[$field] === '' or !isset($_POST[$field]))) {
                 $this->setContextualError($field, "{$this->fields[$field]['display']} is required");
             }
             /**
              * Validate input based on field types
              */
             switch ($this->fields[$field]['input']) {
                 case 'password':
                     if (!empty($_POST[$field . '_blank'])) {
                         // Not much to do really
                     } else {
                         if (empty($_POST[$field]) and empty($_POST[$field . '_confirm'])) {
                             continue 2;
                         } else {
                             if ($_POST[$field] != $_POST[$field . '_confirm']) {
                                 $this->setContextualError($field, 'Passwords entered did not match');
                             }
                         }
                     }
                     break;
                 case 'email':
                     $regex = "/^([*+!.&#\$|'\\%\\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\\.)+[0-9a-z]{2,4})\$/i";
                     if (!empty($_POST[$field]) and !preg_match($regex, $_POST[$field])) {
                         $this->setContextualError($field, "Not a valid email address");
                     }
                     break;
                 case 'bitmask':
                     $v = 0;
                     if (!empty($_POST[$field])) {
                         foreach ($_POST[$field] as $bit) {
                             $v |= $bit;
                         }
                     }
                     $_POST[$field] = $v;
                     break;
             }
             /**
              * Handle validation callbacks
              */
             if (!empty($this->validationCallbacks[$field])) {
                 foreach ($this->validationCallbacks[$field] as $c) {
                     $_POST[$field] = call_user_func($c, $this, $_POST[$field]);
                 }
             }
             /**
              * Add the input to the collected data arrays
              */
             $unQuoted[$field] = $_POST[$field];
             $quoted[$field] = $this->dbQuote($_POST[$field]);
             /**
              * Add to list of fields
              */
             $fields[] = $field;
         }
         /**
          * If there are any errors, show the page again
          */
         if (!empty($this->errors) or !empty($this->contextErrors)) {
             $this->displayAddEditCopyPage($id);
             // Doesn't return
         }
         /**
          * Create the SET ... part of the sql query
          */
         foreach ($fields as $f) {
             $sets[] = "{$f} = {$quoted[$f]}";
         }
         $sets = implode(', ', $sets);
         /**
          * Edit specific
          */
         if (isset($_GET['edit'])) {
             /**
              * Data filters (just in case)
              */
             if (!empty($this->dataFilters)) {
                 $filters = implode(' AND ', $this->dataFilters);
             } else {
                 $filters = 1;
             }
             list($tables, $joinClause) = $this->getQueryTables();
             $sql = "UPDATE {$tables} SET {$sets} WHERE {$joinClause} AND {$filters} AND {$this->pk} = {$id}";
             $res = $this->dbQuery($sql);
             if (!$res) {
                 $this->errors[] = "Failed to update row: " . $this->dbError();
             } else {
                 // Run edit callbacks
                 if (!empty($this->editCallbacks)) {
                     foreach ($this->editCallbacks as $c) {
                         call_user_func($c, $unQuoted);
                     }
                 }
             }
             /**
              * Add/Copy specific
              */
         } else {
             if (!empty($_GET['add']) or isset($_GET['copy'])) {
                 $sql = "INSERT INTO {$this->table} SET {$sets}";
                 $res = $this->dbQuery($sql);
                 if (!$res) {
                     $this->errors[] = "Failed to add row: " . $this->dbError();
                 } else {
                     // FIXME: Need to take into account non auto_increment primary keys
                     $id = $this->dbGetOne("SELECT LAST_INSERT_ID()");
                     if (!empty($_GET['add'])) {
                         // Run addition callbacks
                         if (!empty($this->addCallbacks)) {
                             foreach ($this->addCallbacks as $c) {
                                 call_user_func($c, $unQuoted);
                             }
                         }
                     } else {
                         if (isset($_GET['copy'])) {
                             // Run copy callbacks
                             if (!empty($this->copyCallbacks)) {
                                 foreach ($this->copyCallbacks as $c) {
                                     call_user_func($c, $unQuoted);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /**
          * Check for errors. If none, redirect if OK was pressed, otherwise
          * redirect back to edit page if Apply was pressed.
          */
         if (empty($this->errors)) {
             if ($_POST['action'] == 'OK') {
                 $url = new TableEditor_URL();
                 $url->removeQueryString('edit');
                 $url->removeQueryString('add');
                 $url->removeQueryString('copy');
                 header('Location: ' . $url->getURL());
                 exit;
             } else {
                 if ($_POST['action'] == 'Apply') {
                     $url = new TableEditor_URL();
                     // Change to edit if this was an addition
                     if (!empty($_GET['add']) or isset($_GET['copy'])) {
                         $url->removeQueryString('add');
                         $url->removeQueryString('copy');
                         $url->addQueryString('edit', $id);
                     }
                     header('Location: ' . $url->getURL());
                     exit;
                 }
             }
         }
     }
     $this->displayAddEditCopyPage($id);
 }
Example #7
0
<?php

$url = new TableEditor_URL();
$url->removeQueryString('edit');
$url->removeQueryString('add');
$url->removeQueryString('idcopy');
//if(isset($_POST["ActionRedirection"]) && (TEChangeRedirection==1))
if (isset($_POST["ActionRedirection"]) && TEChangeRedirection == 1) {
    $RecordId = str_replace("'", "", $id);
    $RedirectionUrl = $url->getURL(true);
    $url->addQueryString('edit', $RecordId);
    $RedirectionEditUrl = $url->getURL(true);
    $url->removeQueryString('edit');
    $url->removeQueryString('idcopy');
    $url->addQueryString('add', '1');
    $RedirectionAddURL = $url->getURL(true);
    if (defined("ADD_REDIRECCION") and $add > 0) {
        $LocationUrl = "" . TEditorPath . "?table=" . ADD_REDIRECCION . "&" . strtolower(TEFieldKey($table)) . "=" . $RecordId;
    } else {
        if ($_POST["ActionRedirection"] == 1) {
            TERedirection($RedirectionUrl);
            exit;
        }
        if ($_POST["ActionRedirection"] == 2) {
            TERedirection($RedirectionEditUrl);
            exit;
        }
        if ($_POST["ActionRedirection"] == 3) {
            TERedirection($RedirectionAddURL);
            exit;
        }
			<?php 
        }
        break;
    case "ban_p_bancos":
        if ($FieldName == "TIPO_MOV_BANCO_ID") {
            $FieldAction = ' OnChange="recarga_bancos_movimiento(this);" ';
            $UrlLinkAdd = new TableEditor_URL();
            if ($edit) {
                $TxtRemove = 'edit';
            } elseif ($add == 1) {
                $TxtRemove = 'add';
            }
            $UrlLinkAdd->removeQueryString($TxtRemove);
            $UrlLinkAdd->removeQueryString("tipo_mov_banco_id");
            $UrlLinkAdd->removeQueryString($table);
            $UrlLinkAdd->addQueryString('table', $table);
            $UrlLinkAdd->addQueryString('add', '1');
            $UrlLinkAdd = $UrlLinkAdd->getURL(true);
            ?>
			<script language="javascript">            
			function recarga_bancos_movimiento(elemento)
			{ 
			  window.location = '<?php 
            echo $UrlLinkAdd;
            ?>
&tipo_mov_banco_id='+document.getElementsByName("TIPO_MOV_BANCO_ID")[0].value;
			}
			</script>
			<?php 
        }
        if ($FieldName == "IVA") {
Example #9
0
function TEButtonsPreviousNext($Id, $Action)
{
    $url = new TableEditor_URL();
    $Buttons = '';
    $Buttons .= '<table cellpadding="0" cellspacing="0" align="center" width="100%">';
    $Buttons .= '<tr>';
    $Buttons .= '<td width="50%" style="text-align:left;">';
    if (TEPreviousRecord($Id)) {
        $url->removeQueryString($Action);
        $url->addQueryString($Action, TEPreviousRecord($Id));
        $UrlPrevious = $url->getURL(true);
        $Buttons .= '<img src="' . TEImagesPath . 'TEActionPrevius.png" srcover="' . TEImagesPath . 'TEActionPreviusOver.png" class="TEInputButton" ';
        $Buttons .= 'onclick="document.location=\'' . $UrlPrevious . '\';" title="' . TEButtonPrevious . '" alt="' . TEButtonPrevious . '">&nbsp;';
    }
    $Buttons .= '</td>';
    $Buttons .= '<td width="50%" style="text-align:right;">';
    if (TENextRecord($Id)) {
        $url->removeQueryString($Action);
        $url->addQueryString($Action, TENextRecord($Id));
        $UrlNext = $url->getURL(true);
        $Buttons .= '<img src="' . TEImagesPath . 'TEActionNext.png" srcover="' . TEImagesPath . 'TEActionNextOver.png" class="TEInputButton" ';
        $Buttons .= 'onclick="document.location=\'' . $UrlNext . '\';" title="' . TEButtonNext . '" alt="' . TEButtonNext . '">&nbsp;';
    }
    $Buttons .= '</td>';
    $Buttons .= '</tr>';
    $Buttons .= '</table>';
    return $Buttons;
}
    echo '</tr>';
}
echo '<tr>';
echo '<td colspan="3" align="center">';
$url = new TableEditor_URL();
if ($edit) {
    $TxtRemove = 'edit';
} elseif ($add == 1) {
    $TxtRemove = 'add';
}
$url->removeQueryString($TxtRemove);
$url->removeQueryString("importa_tabla");
$url->removeQueryString("importa_id");
$okURL = $url->getURL(false);
if ($edit) {
    $url->addQueryString('view', $edit);
    $ViewURL = $url->getURL(true);
    $url->removeQueryString('view');
}
$url->addQueryString('add', '1');
$AddURL = $url->getURL(false);
$url->removeQueryString('add');
if ($edit) {
    $Copy = "idcopy";
    $url->addQueryString($Copy, $edit);
    $CopyURL = $url->getURL(false);
    $url->removeQueryString($Copy);
}
if ($edit) {
    $url->addQueryString('delete[]', $edit);
    $DelURL = $url->getURL(false);