function hMover() { // Get the parent table, and the "left" side, which is us $dd = ContextGet('drilldown', array()); $tpar = $dd[0]['page']; $tleft = $this->table_id; // The right side we *assume* is the other parent table // of us that is not the drilldown source. Get it? It breaks // of course if this table has more than one parent $tables = array_keys($this->table['fk_parents']); unset($tables[$tpar]); $tright = array_pop($tables); // if > 1 parent, this won't work $dd_right = dd_tableref($tright); // Get match expression for left-hand side $matches = $dd[0]['parent']; $pmatch = ''; foreach ($matches as $key => $value) { $ileft = $key; $imatch = SQLFC($value); $pmatch .= $key . "='" . $value . "'"; } // Do an insert if coming through as ajax $sqins = ''; if (gpExists('moveradd')) { if (gp('moveradd') != '0') { $row1 = array($dd_right['pks'] => gp('moveradd')); $row2 = $dd[0]['parent']; $rowi = array_merge($row1, $row2); SQLX_Insert($this->table_id, $rowi); } else { $tab = $this->table_id; $cols = $this->table['pks']; $colr = $dd_right['pks']; $sqins = "insert into {$tab}\n ( {$cols} ) \n SELECT {$imatch}, {$colr} \n FROM {$tright}\n WHERE NOT EXISTS (\n SELECT * FROM {$tleft}\n WHERE {$tleft}.{$key} = {$imatch}\n AND {$tleft}.{$colr} = {$tright}.{$colr})"; SQL($sqins); } } // Do a delete if coming through as ajax $sqldel = 'hi'; if (gpExists('moverdel')) { $sqldel = 'moverdel exists'; if (gp('moverdel') != '0') { $sqldel = "delete from " . ddTable_idResolve($this->table_id) . " where skey=" . SQLFN(gp('moverdel')); //echo "echo|$sq"; } else { $sqldel = "delete from " . ddTable_idResolve($this->table_id) . " WHERE " . $pmatch; } SQL($sqldel); } # Pull the source table, the right-hand side # KFD 6/9/08, make left hand side sort by description # if present. $vright = ddTable_idResolve($tright); $vleft = ddTable_idResolve($tleft); $ob = $dd_right['pks']; $ljoin = ''; $lob = ''; if (isset($dd_right['flat']['description'])) { $ob = 'description'; $ljoin = " JOIN {$vright} r ON {$vleft}." . $dd_right['pks'] . '=r.' . $dd_right['pks']; $lob = ' ORDER BY r.description'; } $sq = "SELECT " . $dd_right['pks'] . " as pk\n ,description\n FROM " . ddTable_idResolve($tright) . "\n WHERE description <> ''\n ORDER BY {$ob}"; $rows_right = sql_allrows($sq, 'pk'); # Left side table. $sq = "SELECT {$vleft}." . $dd_right['pks'] . " as pk,{$vleft}.skey\n FROM " . ddTable_IDResolve($this->table_id) . $ljoin . ' ' . " WHERE {$pmatch} {$lob}"; $rows_left = sql_allrows($sq, 'pk'); // Convert the left hand side into options $ahl = array(); foreach ($rows_left as $row) { if (isset($rows_right[trim($row['pk'])])) { $ahl[] = "<OPTION " . ' VALUE="' . $row['skey'] . '"' . '>' . $rows_right[trim($row['pk'])]['description'] . '</option>'; } } // Convert the right hand side into options $ahr = array(); foreach ($rows_right as $row) { if (!isset($rows_left[trim($row['pk'])])) { $ahr[] = "<OPTION " . ' VALUE="' . $row['pk'] . '"' . '>' . $row['description'] . '</option>'; } } ob_start(); ?> <table class="table table-bordered table-striped table-condensed"> <tr> <td> <b>Selected Values</b><br/><br/> <select size=20 style="width: 250px" onclick="formPostAjax('&gp_xajax=1&moverdel='+this.value)" > <?php echo implode("\n", $ahl); ?> </select> <td style="padding:10px; vertical-align: top"> <br/> <br/> <button onclick="formPostAjax('&gp_xajax=1&moveradd=0')" ><< All</button> <br/> <br/> <button onclick="formPostAjax('&gp_xajax=1&moverdel=0')" >All >></button> <td> <b>Available Values</b><br/><br/> <select size=20 style="width: 250px" onclick="formPostAjax('&gp_xajax=1&moveradd='+this.value)" > <?php echo implode("\n", $ahr); ?> </select> </table> <?php $this->h['Content'] = ob_get_clean(); if (gpexists('gp_xajax')) { echo 'mover|' . $this->h['Content']; if (errors()) { echo "|-|echo|" . asErrors(); } exit; } else { $this->h['Content'] = '<div id="mover">' . $this->h['Content'] . '</div>'; } }
function mainMD5() { if (gpexists('md5') && !gpExists('gpp')) { gpSet('gpp', '2'); } $gpp = gp('gpp'); if (gp('gpp') == '3') { $this->MD5_ForgotPage3(); } // process new pw if (gp('gpp') == '2') { $this->MD5_ForgotPage2(); } // link back if (gp('gpp') == '1') { $this->MD5_ForgotPage1(); } // send email if (Errors() || $gpp == '') { $this->MD5_ForgotPage0(); } // get info Hidden("gp_page", "x_password"); }