Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 11. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Problem with a query and layout

phpMyEdit General     Problem with a query and layout
Odoslať novú tému   Odpovedať na tému    
 
vatastala     Založený: 25.02.2009   Príspevky: 3  
Príspevok Zaslal: 2009-02-25 10:49
Návrat hore  Odpovedať s citátom     

Hi, I use phpmyedit for a web interface with different fields. Three of theese are:

Start Time (HH:MM:SS)
End Time (HH:MM:SS)
Difference

My problem is: when I insert start_time and end_time, I need to use a function for calculate the difference end_time - start_time and save It in my database, than the field Difference is automatic and no one can put something in. What can I do to resolve this problem???

Another problem is...When I click the button "add" in the main page to insert a new line, I need to change the layout of the next page, but I see that the http address is the same of the main page, than I think that phpmyedit doesn't load a new page.

Thank you in advance, bye

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-02-25 14:55
Návrat hore  Odpovedať s citátom     

Since it's a self processing script, the URL will always be the same (except the parameters following the page name in the URL will change depending on the current action). I think the following is reasonably accurate in terms of determining page mode.

Kód:
// Determine current page mode, and then display A HREF tags with filters.

$_REQUEST['PME_sys_operation']    (if set) will return one of View, Change, Copy, or Delete

If the above is not set then one of the following is probably set.

$_REQUEST['PME_sys_canceladd']    (if set) returns Cancel
$_REQUEST['PME_sys_cancelchange'] (if set) returns Cancel
$_REQUEST['PME_sys_cancelcopy']   (if set) returns Cancel
$_REQUEST['PME_sys_canceldelete'] (if set) returns Cancel
$_REQUEST['PME_sys_cancelview']   (if set) returns Cancel

$_REQUEST['PME_sys_moreadd']      (if set) returns More

$_REQUEST['PME_sys_morechange']   (if set) returns Apply

$_REQUEST['PME_sys_saveadd']      (if set) returns Save
$_REQUEST['PME_sys_savechange']   (if set) returns Save
$_REQUEST['PME_sys_savecopy']     (if set) returns Save
$_REQUEST['PME_sys_savedelete']   (if set) returns Save


As for time Difference, you would probably need to write a trigger to update the Difference after the record is inserted or updated. However, at the moment I can't think of an easy way to do this. A date field would also be required (?) since in theory the time period could begin on Monday and end on Tuesday. PHP's time() function and MySQL's FROM_UNIXTIME function will probably be part of the solution.

 
vatastala     Založený: 25.02.2009   Príspevky: 3  
Príspevok Zaslal: 2009-02-25 16:42
Návrat hore  Odpovedať s citátom     

I just tried with trigger but doesn't work at the moment...I thought that I can use a function found over internet as in the end of the code:

**************************************************
Kód:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
      
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <title>tar2</title>
<style type="text/css">
body
{
font: 9pt Arial,Verdana,Sans;
link:#000066; alink:#000066; vlink:#000066;
style: color:#000066;
text-decoration:none;
}

TABLE
{
border:#CCCCCC 1px solid;
border-collapse: collapse;
padding: 1px; border-spacing: 1px;
font: 9pt Arial,Verdana,Sans;
}

th
{
border:#FFFFFF 2px solid;
padding: 2px;
background: #d4d4d4;
font: 9pt Arial,Verdana,Sans; font-weight: bold;
}

td
{
border:#FFFFFF 2px solid;
padding: 2px;
text-align: left;
}

hr
{
color:#FFFFFF;
border: 2px solid;
padding: 2px;
margin: 0px;
border-top-width: 1px;
height: 1px;
}

a
{
text-decoration:none;
color:#000066;
}

a:hover
{
text-decoration:underline;
color:#000066;
}

input, textarea
{
background:#FFFFFF;
border:1px #97B9E6 solid;
color: #000000;
font: 9pt Arial,Verdana,Sans;
}

select
{
background-color:#dcdcdc;
border:1px #dcdcdc solid;
color: #dcdcdc;
font: 9pt Arial,Verdana,Sans;
}

input.pme-add, input.pme-cancel, input.pme-change, input.pme-clear, input.pme-copy, input.pme-delete,
input.pme-first, input.pme-goto, input.pme-hide, input.pme-last, input.pme-more,
input.pme-navigation-0, input.pme-navigation-1, input.pme-next, input.pme-prev,
input.pme-query, input.pme-save, input.pme-search, input.pme-view
{
background:#efefef;
border:1px #dcdcdc solid;
color: #000066;
font: 9pt Arial,Verdana,Sans; text-align: center;
}

tr.pme-filter, tr.pme-sortinfo, select.pme-filter, select.pme-filter-right-align,
.pme-clear, .pme-hide, .pme-search
{
background:#e6e6e6;
border:1px #dcdcdc solid;
color: #000066;
font: 9pt Arial,Verdana,Sans; text-align: center;
}

input.pme-filter,
input.pme-filter-right-align
{
background:#FFFFFF;
border:1px #dcdcdc solid;
color: #000066;
font: 9pt Arial,Verdana,Sans; text-align: center;
}

input.pme-input-0,
input.pme-input-1
{
background:#FFFFFF;
border:1px #dcdcdc solid;
color: #000000; font: 9pt Arial,Verdana,Sans;
}

textarea.pme-input-0,
textarea.pme-input-1
{
background:#FFFFFF;
border:1px #dcdcdc solid;
color: #000000;
font: 9pt Arial,Verdana,Sans;
}

select.pme-input-0,
select.pme-input-1
{
background:#fcfcfc;
border:1px #dcdcdc solid;
color: #000000;
font: 9pt Arial,Verdana,Sans;
}

table.pme-navigation
{
background:#FFFFFF;
border:0px;
padding: 1px; cellpadding: 0px;
border-spacing: 1px;
font: 9pt Arial,Verdana,Sans;
}

tr.pme-navigation
{
background:#FFFFFF;
border:0px;
padding: 1px; cellpadding: 1px;
border-spacing: 0px;
cellpadding: 0;
}

td.pme-cell-0
{
background:#f5f5f5;
border-collapse:collapse;
font: 9pt Arial,Verdana,Sans; text-align: center;
}

td.pme-cell-1
{
background:#fafafa;
border-collapse:collapse;
font: 9pt Arial,Verdana,Sans; text-align: center;
}

td.pme-key-0, td.pme-key-1
{
background:#dcdcdc;
border-collapse:collapse;
font: 9pt Arial,Verdana,Sans; font-weight: bold; text-align: left;
}

td.pme-value-0-right-align, td.pme-value-0,
td.pme-value-1-right-align, td.pme-value-1
{
background:#f4f4f4;
border-collapse:collapse;
font: 9pt Arial,Verdana,Sans; text-align: left;
}

td.pme-help-0-right-align, td.pme-help-0,
td.pme-help-1-right-align, td.pme-help-1
{
background:#e8e8e8;
border-collapse:collapse;
font: Arial 10pt; text-align: left;
}

a.pme-navigation-0, a.pme-navigation-1,
a.pme-navigation-0:hover, a.pme-navigation-1:hover,
td.pme-navigation-0, td.pme-navigation-1
{
background:#e6e6e6;
border-collapse:collapse;
font: 9pt Arial,Verdana,Sans; text-align: center;
}

td.pme-buttons
{
background:#FFFFFF;
border:1px #FFFFFF solid;
color: #000066;
font: 9pt Arial,Verdana,Sans; text-align: left;
}

td.pme-message
{
text-align: center;
font: 8pt Arial,Verdana,Sans;
}

td.pme-stats
{
text-align: right;
font: 8pt Arial,Verdana,Sans;
}
</style>

<script type="text/javascript" src="js/jscalendar/calendar.js"></script>
<script type="text/javascript" src="js/jscalendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="js/jscalendar/calendar-setup.js"></script>
<link rel="stylesheet" type="text/css" media="screen"
href="js/jscalendar/calendar-system.css">


               
</head>
<body>
<h3>tar2</h3>
<?php

/*
* IMPORTANT NOTE: This generated file contains only a subset of huge amount
* of options that can be used with phpMyEdit. To get information about all
* features offered by phpMyEdit, check official documentation. It is available
* online and also for download on phpMyEdit project management page:
*
* http://platon.sk/projects/main_page.php?project_id=5
*
* This file was generated by:
*
*                    phpMyEdit version: 5.7.1
*       phpMyEdit.class.php core class: 1.204
*            phpMyEditSetup.php script: 1.50
*              generating setup script: 1.50
*/

// MySQL host name, user name, password, database, and table
$opts['hn'] = 'localhost';
$opts['un'] = 'root';
$opts['pw'] = 'password';
$opts['db'] = 'tar 2009';
$opts['tb'] = 'tar';

// Name of field which is the unique key
$opts['key'] = 'Data';

// Type of key field (int/real/string/date etc.)
$opts['key_type'] = 'date';

// Sorting field(s)
$opts['sort_field'] = array('Data');

// Number of records to display on the screen
// Value of -1 lists all records in a table
$opts['inc'] = 15;

// Options you wish to give the users
// A - add,  C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
$opts['options'] = 'ACPVDF';

// Number of lines to display on multiple selection filters
$opts['multiple'] = '4';

// Navigation style: B - buttons (default), T - text links, G - graphic links
// Buttons position: U - up, D - down (default)
$opts['navigation'] = 'DB';

// Display special page elements
$opts['display'] = array(
   'form'  => true,
   'query' => true,
   'sort'  => true,
   'time'  => true,
   'tabs'  => true
);

// Set default prefixes for variables
$opts['js']['prefix']               = 'PME_js_';
$opts['dhtml']['prefix']            = 'PME_dhtml_';
$opts['cgi']['prefix']['operation'] = 'PME_op_';
$opts['cgi']['prefix']['sys']       = 'PME_sys_';
$opts['cgi']['prefix']['data']      = 'PME_data_';

/* Get the user's default language and use it if possible or you can
   specify particular one you want to use. Refer to official documentation
   for list of available languages. */
$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';

/* Table-level filter capability. If set, it is included in the WHERE clause
   of any generated SELECT statement in SQL query. This gives you ability to
   work only with subset of data from table.

$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200";
*/

/* Field definitions
   
Fields will be displayed left to right on the screen in the order in which they
appear in generated list. Here are some most used field options documented.

['name'] is the title used for column headings, etc.;
['maxlen'] maximum length to display add/edit/search input boxes
['trimlen'] maximum length of string content to display in row listing
['width'] is an optional display width specification for the column
          e.g.  ['width'] = '100px';
['mask'] a string that is used by sprintf() to format field output
['sort'] true or false; means the users may sort the display on this column
['strip_tags'] true or false; whether to strip tags from content
['nowrap'] true or false; whether this field should get a NOWRAP
['select'] T - text, N - numeric, D - drop-down, M - multiple selection
['options'] optional parameter to control whether a field is displayed
  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
            Another flags are:
            R - indicates that a field is read only
            W - indicates that a field is a password field
            H - indicates that a field is to be hidden and marked as hidden
['URL'] is used to make a field 'clickable' in the display
        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
['URLtarget']  HTML target link specification (for example: _blank)
['textarea']['rows'] and/or ['textarea']['cols']
  specifies a textarea is to be used to give multi-line input
  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
['values'] restricts user input to the specified constants,
           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
['values']['table'] and ['values']['column'] restricts user input
  to the values found in the specified column of another table
['values']['description'] = 'desc_column'
  The optional ['values']['description'] field allows the value(s) displayed
  to the user to be different to those in the ['values']['column'] field.
  This is useful for giving more meaning to column values. Multiple
  descriptions fields are also possible. Check documentation for this.
*/

$opts['fdd']['Data'] = array(
  'name'     => 'Data',
  'select'   => 'T',
  'maxlen'   => 10,
  'sort'     => true,
  'calendar' => array(
           'ifFormat'    => '%Y-%m-%d', // defaults to the ['strftimemask']
           'firstDay'    => 1,          // 0 = Sunday, 1 = Monday
           'singleClick' => true,       // single or double click to close
           'weekNumbers' => true,       // Show week numbers
           'showsTime'   => false,      // Show time as well as date
           'timeFormat'  => '24',       // 12 or 24 hour clock
           'button'      => true,       // Display button (rather then clickable area)
         'label'       => '...',      // button label (used by phpMyEdit)
           'date'        => '2003-12-19 10:00' // Initial date/time for popup
                                               // (see notes below)
         )
);
$opts['fdd']['Start_Time'] = array(
  'name'     => 'Start Time',
  'select'   => 'T',
  'maxlen'   => 8,
  'sqlw'     => 'IF($val_qas = "", NULL, $val_qas)',
  'sort'     => true
);
$opts['fdd']['End_Time'] = array(
  'name'     => 'End Time',
  'select'   => 'T',
  'maxlen'   => 8,
  'sqlw'     => 'IF($val_qas = "", NULL, $val_qas)',
  'sort'     => true
);
$opts['fdd']['ImpattoSLA'] = array(
  'name'     => 'ImpattoSLA',
  'select'   => 'T',
  'maxlen'   => 8,
  'sqlw'     => 'IF($val_qas = "", NULL, $val_qas)',
  'sort'     => true
);
function timeDiff($t1, $t2)
{
   if($t1 > $t2)
   {
      $time1 = $t2;
      $time2 = $t1;
   }
   else
   {
      $time1 = $t1;
      $time2 = $t2;
   }
   $diff = array(
      'years' => 0,
      'months' => 0,
      'weeks' => 0,
      'days' => 0,
      'hours' => 0,
      'minutes' => 0,
      'seconds' =>0
   );
   
   foreach(array('years','months','weeks','days','hours','minutes','seconds')
         as $unit)
   {
      while(TRUE)
      {
         $next = strtotime("+1 $unit", $time1);
         if($next < $time2)
         {
            $time1 = $next;
            $diff[$unit]++;
         }
         else
         {
            break;
         }
      }
   }
   return($diff);
}


// Now important call to phpMyEdit
require_once 'extensions/phpMyEdit-mce-cal.class.php';
new phpMyEdit_mce_cal($opts);

?>


</body>
</html>

*****************************************************

and pass the result to field "ImpattoSLA"...How can I pass it???

 
vatastala     Založený: 25.02.2009   Príspevky: 3  
Príspevok Zaslal: 2009-02-25 18:17
Návrat hore  Odpovedať s citátom     

FANTASTIC!!! Now It works!!!


SET NEW.`ImpattoSLA`=TIMEDIFF(NEW.`End_Time`,NEW.`Start_Time`);
END

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov