Location: PHPKode > projects > CSTracker > cstracker2-beta1/templates/customerTemplate.php
<?php
/*
 * Created on Jul 23, 2009
 *
 * Author:: Muhammed Nilufer Nilar
 *
 */
require_once('../classes/Customer.php');
require_once('../classes/Plan.php');

if( isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == false ) {
//echo "dfsd";exit;
//echo "<pre>";print_r($_GET);print_r($_POST);print_r($_SESSION);exit;
	header("Location: ./login.php");
	exit();
}
//if(!$_SESSION['loggedin']) {
////echo "<pre>";print_r($_GET);print_r($_POST);print_r($_SESSION);exit;
//	header("Location: ./login.php");
////	exit();
//}

//if(!isset($_GET['code'])){
//    //$obj = new SupportRequest();
//    //echo "text";
//    flushCustomerTemplate();
//}
function flushCustomerTemplate($obj=null, $msg=null){
?>
    <html>
        <head>
            <title>Customer Form</title>
            <link rel="stylesheet" type="text/css" href="../templates/css/css.css">
            <!-- Author:  Bazillyo - hide@address.com - http://www.geocities.com/bazillyo/spiffy/calendar/ -->
            <!-- Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/ -->
            <link rel="stylesheet" type="text/css" href="../js/spiffyCal.css">
            <script language="JavaScript" src="../js/spiffyCal.js"></script>
            <script language="javascript">
               var cal1=new ctlSpiffyCalendarBox("cal1", "customerForm", "txtstartdate","btnDate1", "<?php if($obj != null) echo $obj->subscStartDate; ?>", 2);
               var cal2=new ctlSpiffyCalendarBox("cal2", "customerForm", "txtenddate","btnDate2", "<?php if($obj != null) echo $obj->subscEndDate; ?>", 2);
            </script>
        </head>
        <body>
            <div id="spiffycalendar" class="text"></div>
            <h2>Customer Form</h2>
            <?php if($msg != null){
                echo $msg;
            }
            ?>
            <form name='customerForm' id='customerForm' onsubmit='validate' method='POST' action='../controllers/CustomerController.php?code=add'>
                <input type='hidden' name='id' id='id' <?php if($obj != null) echo "value=" . $obj->id; ?> />
            <table>
                <tr class="odd">
                    <td><label><?php echo "Company Name";?></label></td>
                        <td><input type='text' name='txtcompanyname' size="40" id='txtcompanyname' <?php if($obj != null) echo 'value="' . $obj->companyName . '"'; ?>/></td>
                </tr>
                <tr class="even">
                    <td><label><?php echo "Address";?></label></td>
                    <td><textarea name='txtaddress' id='txtaddress' cols="35" rows="3"><?php if($obj != null) echo $obj->address; ?></textarea></td>
                </tr>
                <tr class="odd">
                    <td><label><?php echo "Phone Number1";?></label></td>
                    <td><input type='text' name='txtphone1' id='txtphone1' size="25" <?php if($obj != null) echo 'value="' . $obj->phone1 . '"'; ?>/></td>
                </tr>
                <tr class="even">
                    <td><label><?php echo "Phone Number2";?></label></td>
                    <td><input type='text' name='txtphone2' id='txtphone2' size="25" <?php if($obj != null) echo 'value="' . $obj->phone2 . '"'; ?>/></td>
                </tr>
                <tr class="odd">
                    <td><label><?php echo "Plan";?></label></td>
                        <td>
                            <select name='cmbplan' id='cmbplan'  size="1">
                            <?php
                                $plans = Plan::fetchAllPlans();
                                //print_r($plans);exit;
                                foreach($plans as $plan){
                            ?>
                                    <option value=<?php echo "'" . $plan->id . "'"; if($obj != null) echo ($obj->plan == $plan->id)? " selected":""; ?>>
                                        <?php echo $plan->name; ?>
                                    </option>
                            <?php
                                }
                            ?>
                            </select>
                        </td>
                </tr>
                <tr class="even">
                    <td><label><?php echo "Subscription Start Date";?></label></td>
                    <!-- <td><input type='text' name='txtstartdate' id='txtstartdate' size="25" <?php //if($obj != null) echo "value='" . $obj->subscStartDate . "'"; ?>/><?php //echo "&nbsp YYYY-mm-dd"; ?></td> -->
                    <td><SCRIPT language="JavaScript">cal1.writeControl();</SCRIPT></td>
                </tr>
                <tr class="odd">
                    <td><label><?php echo "Subscription End Date";?></label></td>
                    <!-- <td><input type='text' name='txtenddate' id='txtenddate' size="25" <?php //if($obj != null) echo "value='" . $obj->subscEndDate . "'"; ?>/><?php //echo "&nbsp YYYY-mm-dd"; ?></td> -->
                    <td><SCRIPT language="JavaScript">cal2.writeControl();</SCRIPT></td>
                </tr>
                <tr class="even">
                    <td><label><?php echo "Description";?></label></td>
                    <td><textarea name='txtdescription' id='txtdescription' cols="35" rows="3"><?php if($obj != null) echo $obj->description; ?></textarea></td>
                </tr>
                <tr class="odd">
                    <td><input type='submit' name='submit' id='submit' value='Save'/></td>
                    <td><?php if($obj != null) echo "Last modified on $obj->lastUpdatedOn by $obj->lastUpdatedBy"; ?></td>
                </tr>
             </table>
            </form>       
        </body>
    </html>
<?php
}

function flushListTemplate($customersArr, $numOfpages, $pgNo){
    ?>
    <html>
        <head>
            <title>Customers List</title>
            <link rel="stylesheet" type="text/css" href="../templates/css/css.css">
        </head>
        <body>
            <?php
                $i = 1;
                echo "Go to page ";
                while($numOfpages != 0){
                    if( $i != $pgNo){
                        echo "<a href='../controllers/CustomerController.php?code=all&pgno=$i'>$i</a> &nbsp ";
                    }
                    else{                        
                        echo "$i &nbsp ";
                    }
                    $numOfpages--;
                    $i++;
                }
            ?>
            <h2>Customers complete list</h2>
            <!-- todo tableborder to be shown -->
            <div class='tableDiv'>
            <table id='RequestList' >
                <tr>
                    <th>ID</th>
                    <th>Company Name</th>
                    <th>Plan</th>
                    <th>Subscription Start Date</th>
                    <th>Subscription End Date</th>
                    <th>Last Updated On</th>
                    <th>Last Updated By</th>
                    <th>Delete</th>
                </tr>
        <?php
            $rowCount = 1;
            foreach($customersArr as $cstmr){
        ?>
                <tr class='<?php echo ($rowCount%2==0)?"even":"odd" ; $rowCount++; ?>'>
                    <td><?php echo $cstmr->id; ?></td>
                    <td><a href="../controllers/CustomerController.php?code=single&id=<?php echo $cstmr->id; ?>"><?php echo $cstmr->companyName; ?></a></td>
                    <td><?php echo $cstmr->plan; ?></td>
                    <td><?php echo $cstmr->subscStartDate; ?></td>
                    <td><?php echo $cstmr->subscEndDate; ?></td>
                    <td><?php echo $cstmr->lastUpdatedOn; ?></td>
                    <td><?php echo $cstmr->lastUpdatedBy; ?></td>
                    <td class="redhighlight"><a href="../controllers/CustomerController.php?code=delete&id=<?php echo $cstmr->id; ?>"><img src="../templates/images/delete4.png" width="35px" height="20px" alt="Delete"/></a></td>
                </tr>
        <?php
            }
        ?>

            </table>
            </div>
        </body>
    </html>
<?php
}
?>
Return current item: CSTracker