Location: PHPKode > projects > MembersGear > membersgear/templates/admin_product_payment_option_m.tpl
{$ADMIN_HEADER}
{php}
{/php}
{literal}
<script type="text/javascript">
 function IsAsAbove(chkB) {
 
    var level1 = GetControl('txtLevel1');
    var level2 = GetControl('txtLevel2');
    var level1_2 = GetControl('txtLevel1_2');
    var level2_2 = GetControl('txtLevel2_2');
    if (level1 && level2 && level1_2 && level2_2) 
    {
            if (chkB.checked)
            {
                level1_2.value = level1.value;
                level2_2.value = level2.value;
            } 
            else 
            {
                level1_2.value = '';
                level2_2.value = '';
            }
    }
    return;
 }
  function GetControl(ControlId) 
  { 
         for (i = 0; i <= document.forms[0].length; ++i) 
         {
            if (document.forms[0].elements[i].id) {
            if (document.forms[0].elements[i].id.toString().indexOf(ControlId) > -1) 
            {
                 return document.forms[0].elements[i];
            }
         }
         }
  } 
</script>
{/literal}
<div id="content" class="setdiv">
    <div id="full-contentdiv">
        <div class="righttop">
            <h2 align="center">
                 {if $IsEdit eq 'yes'}Update Product/Subscription Payment Options and Commission Payout{else}Add Product/Subscription Payment Options and Commission Payout {/if}
            </h2>
        </div>
        <div class="whole-page clear">
            {if $IsEdit eq 'yes'}
                    {assign var="action" value="update"}
              {else}
                    {assign var="action" value="insert"}
                    {assign var="idnurl1" value="ipn.php"}
              {/if}
            <form name="frmproductpaymentoption" id="frmproductpaymentoption" action="admin_product_payment_option_m.php?action={$action}" method="post" enctype="multipart/form-data">  
                 <div class="borderless borderless-1"> 
                   <table border="1" cellpadding="0" cellspacing="0" style="width:800px" align="center">
                     <tr>
                            <td colspan="2"> 
                                    <div class="horizontal-line">
                                    &nbsp;
                                    </div>
                            </td>
                    </tr>
                     <tr>
                           <td class="right-side-text-borderless space" valign="top" style=""><label>
                              Product : 
                              </label>
                            </td>
                            <td class="left-side-text-borderless">
                            <input type="text" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].name}{else}{$lsproductname}{/if}" class="txtcss"   maxlength="100" id="txttitle" name="txttitle"  disabled style="width: 554px ! important;border:0px;">   
                            
                            </td>
                    </tr> 
                    
                     <tr>    
                        <td class="right-side-text-borderless space" valign="top" style=""><label>
                             Commission Type : <label class="star">*</label>   
                            </label>
                            </td>
                            <td class="left-side-text-borderless">
                               <select id="ddlCommissionType" name="ddlCommissionType" class="selectcss"  style="width: 560px ! important;"  onchange="toggleVisibility1(this.value)" >
                                    <option value=''>select..</option>
                                    {foreach from=$lacommisiontype item="lacommisiontypeitem" key="k"} 
                                        <option value="{$k}"  
                                            {if $IsEdit eq 'yes'}
                                                {if $productcommisiondata[0].commissiontypeid eq $k}
                                                   selected=""
                                           {/if} 
                                           {elseif $IsEdit eq ''}
                                                
                                           {elseif $post.lacommisiontypeitem eq $k} 
                                                   selected=""
                                           {/if} >{$lacommisiontypeitem}</option>
                                    {/foreach}                                    
                                    </select>   
                                <div class="comment-div"  style="width:540px">
                                 Please select "Yes" if you would like to sell this product through PayGear.com.
                                </div> 
                               
                                <div class="comment-div" name="affCommision" id="affCommision"  style="width:540px;display:none">
                                 Please Select Comision Type Fixed or Percentage   
                                </div>
                            </td>
                    </tr>      
                     <tr>
                           <td class="right-side-text-borderless space" valign="top" style=""><label>
                              Commission Level1 : <label class="star">*</label>
                              </label>
                            </td>
                            <td class="left-side-text-borderless">
                               <input type="text" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].commissionlevel1}{else}{$post.txtLevel1}{/if}" class="txtcss" maxlength="14" id="txtLevel1" name="txtLevel1" style="width: 554px ! important;" onmouseover="className='txthover';" onmouseout="className='txtcss';">   
                                <div class="comment-div" style="width:540px">
                                     Please enter 50, if you intend to give 50% commission. 
                                </div>
                            </td>
                    </tr>       
                     <tr>
                           <td class="right-side-text-borderless space" valign="top" style=""><label>
                               Commission Level2 : <label class="star">*</label>
                              </label>
                            </td>
                            <td class="left-side-text-borderless">
                               <input type="text" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].commissionlevel2}{else}{$post.txtLevel2}{/if}" class="txtcss" maxlength="14" id="txtLevel2" name="txtLevel2" style="width: 554px ! important;" onmouseover="className='txthover';" onmouseout="className='txtcss';">   
                                <div class="comment-div" style="width:540px">
                                       Please enter 0 for commission level 2, if you are not offering 2nd level affiliate commissions. 
                                </div>
                            </td>
                    </tr>     
                    <tr>
                    
                    </tr>
                   {if $lsrecurring=="1"}
                      <tr>
                      <td class="right-side-text-borderless space" valign="top" style=""><label>
                              <b> For rest of the subscription payments<B> 
                              </label>
                            </td>
                               <td class="left-side-text-borderless">
                                <input type="checkbox" onclick="return IsAsAbove(this)" value="1" name="chkAsAbove"  id="chkAsAbove" style="" class="chkcss"
                                           {if $IsEdit eq 'yes'}
                                                {if $productdata[0].isallaffiliateapprovedbydefault eq "1"}
                                                  checked=""
                                           {/if} 
                                           {elseif $post.chkAsAbove eq "1"} 
                                                  checked=""
                                           {/if}>As Above  
                                           <div class="comment-div"  style="width:540px">
                                           
                                            </div>
                            </td>
                    </tr>
                   
                    <tr>
                      <td class="right-side-text-borderless space" valign="top" style=""><label>
                               Commission Level2 : <label class="star">*</label>
                              </label>
                            </td>
                            <td class="left-side-text-borderless">
                               <input type="text" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].commissionlevel1restof}{else}{$post.txtLevel1_2}{/if}" class="txtcss" maxlength="14" id="txtLevel1_2" name="txtLevel1_2" style="width: 554px ! important;" onmouseover="className='txthover';" onmouseout="className='txtcss';">   
                                <div class="comment-div" style="width:540px">
                                       Please Enter Commission Level1
                                </div>
                            </td>
                    </tr>
                    
                      <tr>
                      <td class="right-side-text-borderless space" valign="top" style=""><label>
                               Commission Level2 : <label class="star">*</label>
                              </label>
                            </td>
                            <td class="left-side-text-borderless">
                               <input type="text" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].commissionlevel2restof}{else}{$post.txtLevel2_2}{/if}" class="txtcss" maxlength="14" id="txtLevel2_2" name="txtLevel2_2" style="width: 554px ! important;" onmouseover="className='txthover';" onmouseout="className='txtcss';">   
                                <div class="comment-div" style="width:540px">
                                       Please Enter Commission Level2.
                                </div>
                            </td>
                    </tr>
                    {/if}
                            <td>&nbsp;</td> 
                         <td class="buttontd">
                                <input type="submit" class="btncss" name="save" {if $IsEdit eq 'yes'}value="Save"{else}value="Submit"{/if} onclick="return CheckCommissionHigherLimit();">
                                <input type="button" class="btncss" name="btnBack" value="Cancel" onclick="goprevpage('admin_product_v.php','{$lsprevpageqs}')"/>
                                <input type="hidden" id="hdnProductPrice" name="hdnProductPrice" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].price}{else}{$hdnProductPrice}{/if}">
                                <input type="hidden" id="hdncommissionid"  name="hdncommissionid" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].commissionid}{else}{$hdncommissionid}{/if}">
                                <input type="hidden" id="hdnpaygearproductid" name="hdnpaygearproductid" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].paygear_productid}{/if}">  
                                <input type="hidden" id="hdnpaygearproducpaymentoptiontid" name="hdnpaygearproducpaymentoptiontid" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].paygear_productpaymentoptionid}{/if}">  
                                <input type="hidden" id="hdnissubscription" name="hdnissubscription" value="{if $IsEdit eq 'yes'}{$productcommisiondata[0].issubscription}{/if}">  
                                <input type="hidden"  id="hdn_prevpage_qs" name="hdn_prevpage_qs" value="{$lsprevpageqs}">  
                         </td>
                    </tr>
                      
                   </table>
                 </div>
            </form>
            {literal}
                <script language="JavaScript" type="text/javascript">
                function IsNumeric(sText) {

            var RegExp = /^(-)?(\d*)(\.?)(\d*)$/;
            var result = sText.match(RegExp);

            return result;
        }

        function CheckCommissionHigherLimit() {
            var level1 = GetControl('txtLevel1');
            var level2 = GetControl('txtLevel2');
            var productprice = GetControl('hdnProductPrice');
            var commissiontype = document.getElementById('ddlCommissionType');
            var selIndex = commissiontype.selectedIndex;
            var commtype = commissiontype.options[selIndex].text;

            if (selIndex == 0) {
                alert('Commission type is required.');
                return false;
            }

            if ((parseFloat(level1.value.length) == 0) && (parseFloat(level2.value.length) == 0)) {
                alert('Commission level 1 and commission level 2 are required.');
                return false;
            }
            else if ((parseFloat(level1.value.length) > 0) && (parseFloat(level2.value.length) == 0)) {
                alert('Commission level 2 is required.');
                return false;
            }
            else if ((parseFloat(level1.value.length) == 0) && (parseFloat(level2.value.length) > 0)) {
                alert('Commission level 1 is required.');
                return false;
            }

            if (commtype == 'Fixed') {
                if ((IsNumeric(level1.value) == null) || (IsNumeric(level2.value) == null)) {
                    alert('Please enter numeric value');
                    return false;
                }

                if (parseFloat(level2.value) > parseFloat(level1.value)) {
                    alert('Commission level 1 should be greater than commission level 2, Please enter valid values.');
                    return false;
                }

                if ((parseFloat(level1.value) > 0) && (parseFloat(level2.value) > 0)) {
                    var Check = 0.95 * parseFloat(productprice.value);
                    var tot = (parseFloat(level1.value) + parseFloat(level2.value));
                    if (tot > Check) {
                        alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values.');
                        return false;
                    }

                    if (parseFloat(level1.value) > parseFloat(Check)) {
                        alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values.');
                        return false;
                    }
                    else {
                        if (parseFloat(level1.value) < parseFloat(level2.value)) {
                            alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values.');
                            return false;
                        }
                        else {
                            var Check2 = parseFloat(Check) - parseFloat(level1.value);
                            if (parseFloat(level2.value) > parseFloat(Check2)) {
                                alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values.');
                                return false;
                            }
                            else {
                                //return true;
                            }
                        }
                    }
                }
                else {
                    var Check = 0.95 * parseFloat(productprice.value);
                    if (parseFloat(level1.value) > parseFloat(Check)) {
                        alert('Max commission can be up to $ ' + Check + ' for both level 1 and level 2. Please enter valid values.');
                        return false;
                    }
                    else {
                        //return true;
                    }
                }
            }
            else {
                if (commtype == 'Percentage') {
                    if ((IsNumeric(level1.value) == null) || (IsNumeric(level2.value) == null)) {
                        alert('Please enter numeric value');
                        return false;
                    }

                    if (parseFloat(level2.value) > parseFloat(level1.value)) {
                        alert('Commission level 1 should be greater than commission level 2, Please enter valid values.');
                        return false;
                    }

                    if ((parseFloat(level1.value) > 0) && (parseFloat(level2.value) > 0)) {
                        var tot = (parseFloat(level1.value) + parseFloat(level2.value));
                        if (tot > 95) {
                            alert('Max commission can be up to 95% for both level 1 and level 2. Please enter valid values.');
                            return false;
                        }
                    }
                    else {
                        if (parseFloat(level1.value) > 95) {
                            alert('Max commission can be up to 95% for both level 1 and level 2. Please enter valid values.');
                            return false;
                        }
                        else {
                            //return true;
                        }
                    }
                }
            }
            

            /////For Subscription Payments Second Offer
            level1 = document.getElementById('txtLevel1_2');
            level2 = document.getElementById('txtLevel2_2');
            productprice = GetControl('hdnProductPrice');
            commissiontype = document.getElementById('ddlCommissionType');
            selIndex = commissiontype.selectedIndex;
            commtype = commissiontype.options[selIndex].text;
           if (level1 && level2) {
            
                if (selIndex == 0) {
                    alert('Commission type is required.');
                    return false;
                }

                if ((parseFloat(level1.value.length) == 0) && (parseFloat(level2.value.length) == 0)) {
                    alert('Commission level 1 and commission level 2 are required for rest of the subscription payments.');
                    return false;
                }
                else if ((parseFloat(level1.value.length) > 0) && (parseFloat(level2.value.length) == 0)) {
                alert('Commission level 2 is required for rest of the subscription payments.');
                    return false;
                }
                else if ((parseFloat(level1.value.length) == 0) && (parseFloat(level2.value.length) > 0)) {
                alert('Commission level 1 is required for rest of the subscription payments.');
                    return false;
                }

                if (commtype == 'Fixed') {
                    if ((IsNumeric(level1.value) == null) || (IsNumeric(level2.value) == null)) {
                        alert('Please enter numeric value in rest of the subscription payments commission');
                        return false;
                    }

                    if (parseFloat(level2.value) > parseFloat(level1.value)) {
                        alert('Commission level 1 should be greater than commission level 2, Please enter valid values  for rest of the subscription payments.');
                        return false;
                    }

                    if ((parseFloat(level1.value) > 0) && (parseFloat(level2.value) > 0)) {
                        var Check = 0.95 * parseFloat(productprice.value);
                        var tot = (parseFloat(level1.value) + parseFloat(level2.value));
                        if (tot > Check) {
                            alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                            return false;
                        }

                        if (parseFloat(level1.value) > parseFloat(Check)) {
                            alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                            return false;
                        }
                        else {
                            if (parseFloat(level1.value) < parseFloat(level2.value)) {
                                alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                                return false;
                            }
                            else {
                                var Check2 = parseFloat(Check) - parseFloat(level1.value);
                                if (parseFloat(level2.value) > parseFloat(Check2)) {
                                    alert('Max commission can be up to $ ' + parseFloat(Check).toFixed(2) + ' for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                                    return false;
                                }
                                else {
                                    return true;
                                }
                            }
                        }
                    }
                    else {
                        var Check = 0.95 * parseFloat(productprice.value);
                        if (parseFloat(level1.value) > parseFloat(Check)) {
                            alert('Max commission can be up to $ ' + Check + ' for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                            return false;
                        }
                        else {
                            return true;
                        }
                    }
                }
                else {
                    if (commtype == 'Percentage') {
                        if ((IsNumeric(level1.value) == null) || (IsNumeric(level2.value) == null)) {
                            alert('Please enter numeric value for rest of the subscription payments');
                            return false;
                        }

                        if (parseFloat(level2.value) > parseFloat(level1.value)) {
                            alert('Commission level 1 should be greater than commission level 2, Please enter valid values for rest of the subscription payments.');
                            return false;
                        }

                        if ((parseFloat(level1.value) > 0) && (parseFloat(level2.value) > 0)) {
                            var tot = (parseFloat(level1.value) + parseFloat(level2.value));
                            if (tot > 95) {
                                alert('Max commission can be up to 95% for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                                return false;
                            }
                        }
                        else {
                            if (parseFloat(level1.value) > 95) {
                                alert('Max commission can be up to 95% for both level 1 and level 2. Please enter valid values for rest of the subscription payments.');
                                return false;
                            }
                            else {
                                return true;
                            }
                        }
                    }
                }
        }
        return;
    }  
     function goprevpage(pagename,qs)
     {
        location.href=pagename+qs;
                 
     } 
    var frmvalidator  = new Validator("frmproductpaymentoption");
    frmvalidator.EnableMsgsTogether();
    frmvalidator.addValidation("ddlCommissionType","dontselect=''","Please Select Commission Type.","document.getElementById('product_lftime').options[document.getElementById('product_lftime').selectedIndex].value=='0'");
    </script>
    {/literal}
      </div>
  </div>
</div>
{$ADMIN_FOOTER}
Return current item: MembersGear