Location: PHPKode > projects > MembersGear > membersgear/admin/admin_thankyoupage_tracking_m.php
<?php

require_once "../config/config.php"; 
require_once "../includes/product_class.php";
require_once INCLUDE_DIR."/users_class.php"; 
$users = new users_class();
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can view products and thankyou page tracking')==false)
{
        Redirect('admin_nopermission.php',true);  
} 
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can manage products and thankyou page tracking')==false)
{
        Redirect('admin_nopermission.php',true);     
} 

$loProductClass = new product_class();

switch($_action)
{
    case 'insert':
           if($_POST)
           {
                   //Insert
                   $lTypes=null;   
                   $query = 'INSERT INTO '.TABLE_PREFIX.'thankyoupage_tracking
                            (trackingby, trackingname, trackingcode, createdon, createdby, createdipaddress,productpaymentoptionid)
                            VALUES(?,?,?,?,?,?,?)';
                  
                  $lsValues = array();
                   
                   $lsValues[0] = $_POST['txtTrackingBy'];
                   $lsValues[1] = $_POST['txtTrackingName'];
                   $lsValues[2] = htmlentities($_POST['txtTrackingCode']); 
                   $lsValues[3] = mktime();
                   $lsValues[4] = $_SESSION[SESSION_PREFIX.'Admin_UserID'];
                   $lsValues[5] = $_SERVER['REMOTE_ADDR'];
                   $lsValues[6] = $_POST['hdnPaymentOptionID'];
                   
                   $lsInsertedrows = $loProductClass->Insert($query,$lsValues,$lTypes);
                   
                   if($lsInsertedrows > 0)
                   {
                        $message->SetMessage('Tracking Code created successfully.');
                   }
                   else
                   {
                        $message->SetMessage('Some error occure while inserting tracking code.');
                   }
                   
                   $query = 'SELECT productid FROM '.TABLE_PREFIX.'productpaymentoptions WHERE id='.$_POST['hdnPaymentOptionID'];
                   $liProductID = $loProductClass->View($query,null,null);       
                   
                   Redirect('admin_thankyoupage_tracking_v.php?productid='.$liProductID[0]['productid']);
           }
           break;
    case 'update':                     
           //Update           
           if($_POST)
           {
                   $lTypes=null;   
                   $query = 'UPDATE '.TABLE_PREFIX.'thankyoupage_tracking SET trackingby=?,trackingname=?,trackingcode=?,modifiedon=?,modifiedby=?,modifiedipaddress=? WHERE id=?';
                   
                   $lsValues = array();
                   
                   $lsValues[0] = $_POST['txtTrackingBy'];
                   $lsValues[1] = $_POST['txtTrackingName'];
                   $lsValues[2] = htmlentities($_POST['txtTrackingCode']); 
                   $lsValues[3] = mktime();
                   $lsValues[4] = $_SESSION[SESSION_PREFIX.'Admin_UserID'];
                   $lsValues[5] = $_SERVER['REMOTE_ADDR'];
                   $lsValues[6] = $_POST['hdnID']; 
                   
                   $lsUpdatedrows = $loProductClass->Update($query,$lsValues,$lTypes);
                   
                   if($lsUpdatedrows > 0)
                   {
                        $message->SetMessage('Tracking Code is updated successfully.');
                   }
                   else
                   {
                        $message->SetMessage('Some error occure while updating records.');
                   }
                   
                   $query = 'SELECT productid FROM '.TABLE_PREFIX.'productpaymentoptions WHERE id='.$_POST['hdnPaymentOptionID'];
                   $liProductID = $loProductClass->View($query,null,null);       
                   
                   Redirect('admin_thankyoupage_tracking_v.php?productid='.$liProductID[0]['productid']);
           }
                   
           break;
    
    case 'edit':
            $lTypes=null;
             $lsValues = array($_GET['id']);
             $query = "SELECT * FROM ".TABLE_PREFIX."thankyoupage_tracking WHERE id=?";
             
             $result = $loProductClass->View($query,$lsValues,null);
             $result[0]['trackingcode'] = html_entity_decode($result[0]['trackingcode']);
             $smarty->assign('data',$result);
             $smarty->assign('IsEdit','yes');
             $smarty->display('admin_thankyoupage_tracking_m.tpl'); 
            break;      
     case 'delete':
             $query = 'DELETE FROM '.TABLE_PREFIX.'thankyoupage_tracking WHERE id='.$_GET['id'];
             $lsDeletedrow = $loProductClass->delete($query,null,null);
             
             if($lsDeletedrow > 0)
            {
                $message->SetMessage('Tracking Code is delete successfully.');
            }
            else
            {
                $message->SetMessage('Some error occure! Please try again.');    
            }
                   
             $quest="&";
                if(isset($_GET) && !empty($_GET))
                 {
                     foreach($_GET as $keyname => $value) {
                          $quest.=$keyname."=".$value."&";
                        }     
                 
                 }      
            Redirect('admin_thankyoupage_tracking_v.php?productid='.$_GET['productid'].$quest); 
             
            break;
    
    default:       
           $data[0]['productpaymentoptionid'] = $_GET['paymentoptionid'];
           $smarty->assign('data',$data);
           $smarty->display('admin_thankyoupage_tracking_m.tpl');
}
?>
Return current item: MembersGear