<?php
/*
+--------------------------------------------------------------------------
|   CubeCart v3.0.11
|   ========================================
|   by Alistair Brookbanks
|	CubeCart is a Trade Mark of Devellion Limited
|   (c) 2005 Devellion Limited
|   Devellion Limited,
|   22 Thomas Heskin Court,
|   Station Road,
|   Bishops Stortford,
|   HERTFORDSHIRE.
|   CM23 3EE
|   UNITED KINGDOM
|   http://www.devellion.com
|	UK Private Limited Company No. 5323904
|   ========================================
|   Web: http://www.cubecart.com
|   Date: Thursday, 27th July 2006
|   Email: sales (at) cubecart (dot) com
|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 
|   Licence Info: http://www.cubecart.com/site/faq/license.php
+--------------------------------------------------------------------------
|	index.php
|   ========================================
|	Configure United States Postal Service
| Reworked Sunday, 26th November 2005 by Sir William
+--------------------------------------------------------------------------
*/
include("../../../../includes/ini.inc.php");
include("../../../../includes/global.inc.php");
require_once("../../../../classes/db.inc.php");
$db = new db();
include_once("../../../../includes/functions.inc.php");
$config = fetchDbConfig("config");

include_once("../../../../language/".$config['defaultLang']."/lang.inc.php");
$enableSSl = 1;
include_once("../../../../includes/sslSwitch.inc.php");
include("../../../includes/auth.inc.php");
include("../../../includes/header.inc.php");

if(permission("settings","read")==FALSE){
	header("Location: ".$GLOBALS['rootRel']."admin/401.php");
	exit;
}

if(isset($_POST['module'])){
	include("../../status.php");
	include("../../../includes/functions.inc.php");
	$module = fetchDbConfig($_GET['folder']);
	$msg = writeDbConf($_POST['module'], $_GET['folder'], $module);
	
}
$module = fetchDbConfig($_GET['folder']);
?>




<p><a href="http://www.usps.com/"><img src="logo.gif" alt="" border="0" title="" /></a></p>
<?php 
if(isset($msg)){ 
	echo stripslashes($msg); 
} 
?>

<form action="<?php echo $GLOBALS['rootRel'];?>admin/modules/<?php echo $_GET['module']; ?>/<?php echo $_GET['folder']; ?>/index.php?module=<?php echo $_GET['module']; ?>&amp;folder=<?php echo $_GET['folder']; ?>" method="post" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="3" class="mainTable">
  <tr>
    <td colspan="5" class="tdTitle">Configuration Settings </td>
  </tr>
  <tr>
    <td align="left" class="tdText"><strong>Status:</strong></td>
    <td class="tdText" colspan="4">
<?php
	if($module['testspassed']==1)
	{ ?>
		<select name="module[status]">
		<option value="1" <?php if($module['status']==1) echo "selected='selected'"; ?>>Enabled</option>
		<option value="0" <?php if($module['status']==0) echo "selected='selected'"; ?>>Disabled</option>
    </select>
    <strong><-- Do not enable until USPS has switched you to <u>Live</u>.</strong></td> <?php	
	} else { ?>
		<strong>Disabled</strong>
    &nbsp; <-- You <strong>MUST</strong> Submit USPS Tests Below to Enable.</td> <?php	
	}
?>
    </tr>
<!-- ### Removed by Sir William Test Mode No Longer Necessary ###
  <tr>
  <td align="left" class="tdText"><strong>Test Mode:</strong></td>
    <td class="tdText"><select name="module[test]">
      <option value="1" <!?php if($module['test']==1) echo "selected='selected'"; ?>>Enabled</option>
      <option value="0" <!?php if($module['test']==0) echo "selected='selected'"; ?>>Disabled</option>
    </select></td>
    <td class="tdText">&nbsp;</td>
    <td class="tdText">&nbsp;</td>
    <td class="tdText">&nbsp;</td>
    </tr>
-->
    <tr>
      <td  class="tdText"><strong>Debugging: </strong></td>
      <td  class="tdText"><select name="module[debug]">
        <option value="1" <?php if($module['debug']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['debug']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select></td>
      <td  class="tdText">&nbsp;</td>
      <td  class="tdText">&nbsp;</td>
      <td  class="tdText">&nbsp;</td>
    </tr>
    <tr>
      <td  class="tdText"><strong>Service Type</strong></td>
      <td  class="tdText"><strong>Status</strong></td>
      <td  class="tdText"><strong>Package Size</strong></td>
      <td  class="tdText"><strong>Container Types</strong></td>
      <td  class="tdText"><strong>Weight Limit</strong></td>
    </tr>
    <tr>
      <td  class="tdText">Express  Mail  </td>
      <td valign="top"  class="tdText">
	  <select name="module[service_Express]">
        <option value="1" <?php if($module['service_Express']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_Express']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	  </td>
      <td valign="top"  class="tdText">
        <select name="module[expressSize]">
        <option value="REGULAR" <?php if($module['expressSize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
		<option value="LARGE" <?php if($module['expressSize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
		</select>      </td>
      <td valign="top"  class="tdText">
	  <select name="module[expressContainer]">
        <option value="Flat Rate Envelope" <?php if($module['expressContainer']=="Flat Rate Envelope") echo "selected='selected'"; ?>>Flat Rate Envelope</option>
      </select>      </td>
      <td valign="top"  class="tdText">70 lbs.</td>
    </tr>
    <tr>
      <td  class="tdText">First Class</td>
      <td valign="top"  class="tdText">
	  <select name="module[service_FirstClass]">
        <option value="1" <?php if($module['service_FirstClass']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_FirstClass']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	  </td>
      <td valign="top"  class="tdText"><select name="module[FirstClassSize]">
        <option value="REGULAR" <?php if($module['FirstClassSize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['FirstClassSize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
      </select></td>
      <td valign="top"  class="tdText">N/A</td>
      <td valign="top"  class="tdText">13 oz.</td>
    </tr>
    <tr>
      <td  class="tdText">Priority Mail </td>
      <td valign="top"  class="tdText">
	  <select name="module[service_Priority]">
        <option value="1" <?php if($module['service_Priority']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_Priority']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	  </td>
      <td valign="top"  class="tdText"><select name="module[prioritySize]">
        <option value="REGULAR" <?php if($module['prioritySize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['prioritySize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
      </select></td>
      <td valign="top"  class="tdText"><select name="module[priorityContainer]">
        <option value="Flat Rate Envelope" <?php if($module['priorityContainer']=="Flat Rate Envelope") echo "selected='selected'"; ?>>Flat Rate Envelope</option>
		<option value="Flat Rate Box" <?php if($module['priorityContainer']=="Flat Rate Box") echo "selected='selected'"; ?>>Flat Rate Box</option>
      </select>      </td>
      <td valign="top"  class="tdText">70 lbs.</td>
    </tr>
    <tr>
      <td  class="tdText">Parcel Post (Machinable) </td>
      <td valign="top"  class="tdText">
	  <select name="module[service_Parcel-M]">
        <option value="1" <?php if($module['service_Parcel-M']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_Parcel-M']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	  </td>
      <td valign="top"  class="tdText"><select name="module[parcel-MSize]">
        <option value="REGULAR" <?php if($module['parcel-MSize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['parcel-MSize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
		<option value="OVERSIZE" <?php if($module['parcel-MSize']=="OVERSIZE") echo "selected='selected'"; ?>>Oversize</option>
      </select></td>
      <td valign="top"  class="tdText">N/A</td>
      <td valign="top"  class="tdText">70 lbs.</td>
    </tr>
    <tr>
      <td  class="tdText">Parcel Post (Non-Machinable) </td>
      <td valign="top"  class="tdText"><select name="module[service_Parcel-NM]">
        <option value="1" <?php if($module['service_Parcel-NM']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_Parcel-NM']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select></td>
      <td valign="top"  class="tdText"><select name="module[parcel-NMSize]">
        <option value="REGULAR" <?php if($module['parcel-NMSize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['parcel-NMSize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
		<option value="OVERSIZE" <?php if($module['parcel-NMSize']=="OVERSIZE") echo "selected='selected'"; ?>>Oversize</option>
      </select></td>
      <td valign="top"  class="tdText">N/A</td>
      <td valign="top"  class="tdText">70 lbs.</td>
    </tr>
    <tr>
      <td  class="tdText">BPM (Bound Printed Matter)</td>
      <td valign="top"  class="tdText">
	  <select name="module[service_BPM]">
        <option value="1" <?php if($module['service_BPM']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_BPM']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	  </td>
      <td valign="top"  class="tdText"><select name="module[BPMSize]">
         <option value="REGULAR" <?php if($module['BPMSize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['BPMSize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
      </select></td>
      <td valign="top"  class="tdText">N/A</td>
      <td valign="top"  class="tdText">15 lbs.</td>
    </tr>
    <tr>
      <td  class="tdText">Library</td>
      <td valign="top"  class="tdText">
	  <select name="module[service_Library]">
        <option value="1" <?php if($module['service_Library']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_Library']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	 </td>
      <td valign="top"  class="tdText"><select name="module[LibrarySize]">
        <option value="REGULAR" <?php if($module['LibrarySize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['LibrarySize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
      </select></td>
      <td valign="top"  class="tdText">N/A</td>
      <td valign="top"  class="tdText">70 lbs.</td>
    </tr>
    <tr>
      <td  class="tdText">Media</td>
      <td valign="top"  class="tdText">
	  
	  <select name="module[service_Media]">
        <option value="1" <?php if($module['service_Media']==1) echo "selected='selected'"; ?>>Enabled</option>
        <option value="0" <?php if($module['service_Media']==0) echo "selected='selected'"; ?>>Disabled</option>
      </select>	  </td>
      <td valign="top"  class="tdText"><select name="module[MediaSize]">
        <option value="REGULAR" <?php if($module['MediaSize']=="REGULAR") echo "selected='selected'"; ?>>Regular</option>
        <option value="LARGE" <?php if($module['MediaSize']=="LARGE") echo "selected='selected'"; ?>>Large</option>
      </select></td>
      <td valign="top"  class="tdText">N/A</td>
      <td valign="top"  class="tdText">70 lbs.</td>
    </tr>
    <tr>
    <td  class="tdText"><strong>Origin Zip Code:</strong><br />      </td>
    <td valign="top"  class="tdText">
      <input type="text" name="module[zip_origin]" value="<?php echo $module['zip_origin']; ?>" class="textbox" />    </td>
    <td valign="top"  class="tdText">&nbsp;</td>
    <td valign="top"  class="tdText">&nbsp;</td>
    <td valign="top"  class="tdText">&nbsp;</td>
    </tr>
  <tr>
    <td  class="tdText"><strong>USPS Username:</strong><br />      </td>
    <td valign="top"  class="tdText">
      <input type="text" name="module[username]" value="<?php echo $module['username']; ?>" class="textbox" />    </td>
    <td valign="top"  class="tdText">&nbsp;</td>
    <td valign="top"  class="tdText">&nbsp;</td>
    <td valign="top"  class="tdText">&nbsp;</td>
    </tr>
      <tr><td align="left" class="tdText"><strong>USPS Password:</strong></td>
    <td class="tdText"><input type="text" name="module[password]" value="<?php echo $module['password']; ?>" class="textbox" /></td>
    <td class="tdText" colspan="3">&nbsp;&lt;-- Currently unused. Must simply be NOT empty.</td>
    </tr>
  <tr>
    <td align="right" class="tdText">&nbsp;</td>
    <td class="tdText"><input type="submit" class="submit" value="Edit Config" /></td>
    <td class="tdText">&nbsp;</td>
    <td class="tdText">&nbsp;</td>
    <td class="tdText">&nbsp;</td>
    </tr>
</table>
<p><strong>Notes:</strong><br />
To get this shipping method to work you must first sign up for an account here <a href="http://www.uspswebtools.com/registration/">http://www.uspswebtools.com/registration/</a>.
The live server will not work until you have had two specific successful transactions on the test server.</p>
<p> &nbsp; &nbsp; &nbsp; <a href="./testSubmit.php?module=<?php echo $_GET['module']; ?>&amp;folder=<?php echo $_GET['folder']; ?>" class="txtLink"><strong>Click Here To Submit USPS Tests</strong></a></p>
<p>Once those have been successful, email USPS at <a href="mailto:icustomercare@usps.com">icustomercare@usps.com</a> or
call them at <strong>1-800-344-7779</strong> (7:00 AM to 11:00 PM EST daily) and they will activate your account to use the live server.</p>
</form>
<?php include("../../../includes/footer.inc.php"); ?>