Jump to content

Recommended Posts

All,

 

Have a file posted at:

 

http://pastebin.ca/840828

 

with 5 buttons.  Problem is I'm having trouble getting the buttons to differentiate themselves.  Been trying to use the function "set_but" to solve this, but not sure I'm calling it correct nor setting up the passing of vars to it right.

 

The purpose of this file, is to read in an Excel file (thus TBS Excel class) and then write data to another Excel file.  Right now, I'm using MySQL to hold the R:C mapping between the files and have not yet set up any MySQL queries, until I can the button to perform their various functions.

 

Buttons are:

  • Browse - From built in <input type=file> field,
  • View Input File - Uses TBS Excel Class to open originating file,
  • Process - Scrapes the data from file1 into file2,
  • View Output File - Process file, if not already done and opens target file with TBS Excel Class,
  • Print Output - Process file, if not already done and print out the resulting target file.

 

Right now all the buttons, other than "Browse" are just opening the originating file.

 

Kinda new on the PHP side, so still feeling my way.

 

All help appreciated!

 

Thanks!

 

OMR

 

 

Link to comment
https://forums.phpfreaks.com/topic/84401-solved-button-control/
Share on other sites

All,

 

Resolved with this code:

<?php
   define('TITLE1', 'Main Title');
   define('TITLE2', 'Subtitle');
   define('ORGFIL', 'source.xls');
   define('ORGSHT', 'sheet1');
   define('OCLROW', '5 324');
   define('TRGFIL', 'target.xls');
   define('TRGSHT', 'sheet2');
   define('TCLROW', '11 57');
   include('Zips/TBS Excel/tbs_class.php');          //Load TBS Class
   include('Zips/TBS Excel/tbs_plugin_excel.php');   //Load TBS plugin

   function open_xcel($myfile,$mysheet) {
      $opn_str = $myfile;
      $TBS = new clsTinyButStrong;
      $TBS->PlugIn(TBS_INSTALL,TBS_EXCEL);
      $TBS->LoadTemplate($myfile);
//      $TBS->MergeBlock('book',$books);               //Process Alternate Cell Mapping
//      $TBS->MergeBlock('tsk1,tsk2',$tasks);          //Process Alternate Cell Mapping
//      $TBS->MergeBlock('emp',$employees);            //Process Alternate Cell Mapping
      $TBS->PlugIn(TBS_EXCEL,TBS_EXCEL_FILENAME,'result.xls');
      $TBS->Show();
   }

   $but_vin = '<button type=submit name=iview onclick="value=\'invw\'">'.
              'View Input File</button>';
   $but_vot = '<button type=submit name=oview onclick="value=\'outv\'">'.
              'View Output File</button>';
   $but_prc = '<button type=submit name=proc onclick="value=\'proc\'">'.
              'Process</button>';
   $but_prt = '<button type=submit name=prnt onclick="value=\'prnt\'">'.
              'Print Output</button>';
   $two_spc = '  ';
   $but_lin = $but_prc.$two_spc.$but_vot.$two_spc.$but_prt;
   $vot_val = '"D:\Local Files\Company Relations, Projects & Bids\Active\Avid Business Networks\avid phone quote.xls"';

   $vin_val = $HTTP_POST_VARS['infil'];
   $fld_vin = "<input type=file size=80 name=infil value=$vin_val ".
              "onclick=\"document.forms['scrub'].submit();\">";
   $fld_vot = "<input type=text size=100 name=otfil value=$vot_val>";
   $vot_val = 'D:\Local Files\Company Relations, Projects & '.
              'Bids\Active\Avid Business Networks\avid phone quote.xls';
   if ($HTTP_POST_VARS['iview']=='invw') {
      $tstbut = $HTTP_POST_VARS['iview'];
   }
   if ($HTTP_POST_VARS['oview'] == 'outv') {
      $tstbut = $HTTP_POST_VARS['oview'];
   }
   if ($HTTP_POST_VARS['proc']=='proc') {
      $tstbut = $HTTP_POST_VARS['proc'];
   }
   if ($HTTP_POST_VARS['prnt']=='prnt') {
      $tstbut = $HTTP_POST_VARS['prnt'];
   }unset ($HTTP_POST_VARS['proc'],$HTTP_POST_VARS['form'],
            $HTTP_POST_VARS['iview'],$HTTP_POST_VARS['oview'],
            $HTTP_POST_VARS['prnt']);
   switch ($tstbut) {
      case 'invw':   // Open/Edit the INPUT file.
         if ($HTTP_POST_VARS['infil'] != "") {
            $vin_val = $HTTP_POST_VARS['infil'];
            $vin_val = realpath($vin_val);
            if (file_exists($vin_val)) {
               $rc = open_xcel($vin_val, ORGSHT);
            } else {
               echo "File => $vin_val <= not found! <br>";
            }
         } else {
            echo "Must select a file to procces or read!";
         }
         break;
      case 'outv':   // Open/Edit the OUTPUT file.
         if ($HTTP_POST_VARS['otfil'] != "") {
            if (file_exists($vot_val)) {
               if ($PROCD == 'Processed') {
                  $rc = open_xcel($vot_val, ORGSHT);
               } else {
                  echo "No OUTPUT File Processed <br>";
               }
            } else {
               echo "File => $vot_val <= not found! <br>";
            }
         }
         break;
      case 'proc':   // Dump the INPUT file into the OUTPUT file.
         if ($HTTP_POST_VARS['infil'] != "") {
            $vin_val = $HTTP_POST_VARS['infil'];
            $vin_val = realpath($vin_val);
            if (file_exists($vin_val)) {
               if ($PROCD != 'Processed') {
//                  $rc = XL_proc($vin_val,$vot_val);
               } else {
                  echo "File already Processed <br>";
               }
            } else {
               echo "File => $vot_val <= not found! <br>";
            }
         } else {
            echo "Must select a file to procces or read!";
         }
         break;
      case 'prnt':
         if ($HTTP_POST_VARS['otfil'] != "") {
            if (file_exists($vot_val)) {
//               $rc = open_xcel($vot_val, ORGSHT);
            } else {
               echo "File => $vot_val <= not found! <br>";
            }
         }
         break;
   }
   $TIT1 = TITLE1;
   $TIT2 = TITLE2;
   ob_start();
?>

<html>
<head>
<title>Excel Scrub Processor</title>
</head>

<body>
<FORM name="scrub" METHOD="POST" ACTION="<?php echo $_SERVER['PHP_SELF']; ?>">
<table width='80%' border=0 align=center>
   <tr height=50>
   <td align=center> </td>
   </tr>

   <tr>
   <td align=center>
   <table width='100%' border=0 align=center bgcolor='#55aaee'>
      <tr>
      <td colspan=4 align=center> </td>
      </tr>

      <tr>
      <td colspan=4 align=center>
          <h1><?php echo $TIT1; ?></h1>
          <b><?php echo $TIT2; ?></b>
      </td>
      </tr>

      <tr>
      <td width=25> </td>
      <td> </td>
      <td> </td>
      <td width=25> </td>
      </tr>

      <tr>
      <td> </td>
      <td>
        <?php echo $fld_vin; ?>
      </td>
      <td align=left width=100>
      <button type=submit name='iview' onclick="value='invw'">View Input File</button>
      </td>
      <td> </td>
      </tr>

      <tr>
      <td> </td>
      <td colspan=2>
        <?php echo $fld_vot; ?> <b><= Output file</b>
      </td>
      <td> </td>
      </tr>

      <tr>
      <td colspan=4> </td>
      </tr>

      <tr>
      <td colspan=4 align=center>
        <?php echo $but_lin; ?>
      </td>
      </tr>

      <tr>
      <td colspan=4> </td>
      </tr>
   </table>
   </tr>
</table>
</form>
</body>
</html>
<?php
   ob_end_flush();
?>

Button processing now working but functions are still in progress.

 

Thanks all!

 

OMR

 

 

Link to comment
https://forums.phpfreaks.com/topic/84401-solved-button-control/#findComment-431342
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.