<?php 

$getpage =$_SERVER['QUERY_STRING']; 

//echo $getpage;

$explode= explode('=',$getpage);

$sid=$explode[2];





//To edit the profile information

$query="SELECT memberID,fname,mname,lname,email,address,floorno,mobile,phone,bloodgroup,billingcontact,zipcode,city,country,openingdate,billingdate,voterid,installamount,c.name AS reseller,c.pid AS resellerID,b.name AS package,b.pid AS packageID,d.name AS area,d.did AS areaid,IP,MAC,a.installamount,a.amount,a.username,a.password,reference FROM ".$prefix."member_personal AS a,".$prefix."package AS b,".$prefix."reseller AS c,".$prefix."location AS d WHERE a.package=b.pid AND a.reseller=c.pid  AND a.area=d.did AND id=$sid";



$profileType=mysqli_query($linkid,$query);

$dataProfile=mysqli_fetch_assoc($profileType);



$query="SELECT did,name FROM ".$prefix."location ORDER BY did ASC";

$locationType=mysqli_query($linkid,$query);



$query="SELECT pid,name FROM ".$prefix."package ORDER BY name ASC";

$packageType=mysqli_query($linkid,$query);



$query="SELECT pid,name FROM ".$prefix."reseller ORDER BY name ASC";

$resellerType=mysqli_query($linkid,$query);

?>



<div id="contentwrapper">

  <div class="main_content">

    <nav>

      <div id="jCrumbs" class="breadCrumb module">

        <ul>

          <li> <a href="#"><i class="icon-home"></i></a> </li>

          <li> <a href="index.php?tab=member">Member</a> </li>

          <li> <a href="index.php?tab=edit-member">Edit Member</a> </li>

        </ul>

      </div>

    </nav>

    <div class="row-fluid">

      <div class="span6">

        <?php

		          	if(isset($_POST['submit']))

						{

						$sprefix=$_POST['sprefix'];

						$serialno=$_POST['serialno'];

						$serial=$sprefix.$serialno;

						$fname=$_POST['fname'];

						$mname=$_POST['mname'];

						$lname=$_POST['lname'];

					

						$email=$_POST['email'];	

						$username=$_POST['username'];

							

						$pass=$_POST['password'];		

						

						$area=$_POST['area'];

						$address=$_POST['address'];

						$floorno=$_POST['floorno'];						

						$mobile=$_POST['mobile'];

						$phone=$_POST['phone'];		

						

						$billingcontact=$_POST['billingcontact'];

						$zipcode=$_POST['zipcode'];

						$city=$_POST['city'];						

						$country=$_POST['country'];

						$openingdate=$_POST['openingdate'];	

						$billingdate=$_POST['billingdate'];	

						$voterID=$_POST['voterID'];	

						$mac=$_POST['MAC'];						

						

						$bloodgroup=$_POST['bloodgroup'];		

						$installamount=$_POST['installamount'];

						$amount=$_POST['amount'];

						$IP=$_POST['IP'];

						$reseller=$_POST['reseller'];

						$package=$_POST['package'];			

						$reference=$_POST['reference'];

						

						//echo $rollno.$studname.$prefix."Hello";	

						

						$query = "UPDATE ".$prefix."member_personal SET fname='$fname',mname='$mname',lname='$lname',email='$email',area='$area',address='$address',floorno='$floorno',mobile='$mobile',phone='$phone',bloodgroup='$bloodgroup',billingcontact='$billingcontact',zipcode='$zipcode',city='$city',country='$country',openingdate='$openingdate',billingdate='$billingdate',voterid='$voterID',reseller='$reseller',package='$package',IP='$IP',MAC='$mac',installamount='$installamount',amount='$amount',username='$username',password='$pass',reference='$reference' WHERE id=$sid";

						$result=mysqli_query($linkid,$query) or die(mysqli_error());					

						

						

						

						if($result){

						?>

        <div class="alert alert-success"> <a data-dismiss="alert" class="close">x</a> <strong>Member</strong> is Updated.&nbsp;&nbsp; </div>

        <script type="text/javascript" language="javascript">

							  setTimeout(function () {

								 window.location.href= 'index.php?tab=edit-member?sid=<?php echo $sid;?>'; // the redirect goes here

								},3000);

							  </script>

        <?php 

						

						 }

						}

							

					 //unlink($filename1);

					 

						 unset($_POST);

						 $_POST['submit']='';

						 $_POST='';

					?>

        <h3 class="heading">Edit Member</h3>

        <h4 class="heading">Personal Information</h4>

        <form class="form_validation_reg" id="form_validation_reg" action=""  method="post" enctype="multipart/form-data">

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Member ID<span class="f_req">*</span></label>

                <input type="text" name="sprefix" id="sprefix" class="span12"  disabled="disabled" value="<?php echo $dataProfile['memberID'];?>"/>

              </div>

              <div class="span4">

                <label>First Name <span class="f_req">*</span></label>

                <input type="text" name="fname" id="fname" class="span12" value="<?php echo $dataProfile['fname'];?>" />

              </div>

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Middle Name</label>

                <input type="text" name="mname" id="mname" class="span12" value="<?php echo $dataProfile['mname'];?>" />

              </div>

              <div class="span4">

                <label>Last Name</label>

                <input type="text" name="lname" id="lname" class="span12" value="<?php echo $dataProfile['lname'];?>" />

              </div>

              <div class="span4">

                <label>Email<span class="f_req">*</span></label>

                <input type="text" name="email" id="email" class="span12" value="<?php echo $dataProfile['email'];?>"/>

              </div>

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Area <span class="f_req">*</span></label>

                <SELECT class="input_text" name="area" id="area">

                  <OPTION SELECTED VALUE="<?php echo $dataProfile['areaid'];?>"><?php echo $dataProfile['area'];?></OPTION>

                  <?php

												if($locationType)

												{

												   while($mydata=mysqli_fetch_row($locationType))

													{

													 echo "<option value='$mydata[0]'>$mydata[1]</option>";

													}

												}	

													?>

                </SELECT>

              </div>

              <div class="span4">

                <label>Address <span class="f_req">*</span> </label>

                <input type="text" name="address" id="address" class="span12" value="<?php echo $dataProfile['address'];?>" />

              </div>

              <div class="span4">

                <label>Floor/Flat <span class="f_req">*</span></label>

                <input type="text" name="floorno" id="floorno" class="span12" value="<?php echo $dataProfile['floorno'];?>" />

              </div>

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Mobile </label>

                <input type="text" name="mobile"  id="mobile"  class="span12" value="<?php echo $dataProfile['mobile'];?>" />

              </div>

              <div class="span4">

                <label>Billing Contact No. <span class="f_req">*</span></label>

                <input type="text" name="billingcontact"  id="billingcontact"  class="span12" value="<?php echo $dataProfile['billingcontact'];?>" />

              </div>

              <div class="span4">

                <label>Phone</label>

                <input type="text" name="phone"  id="phone" class="span12"  value="<?php echo $dataProfile['phone'];?>"/>

              </div>

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>ZIP</label>

                <input type="text" name="zipcode" id="zipcode" class="span12" value="<?php echo $dataProfile['zipcode'];?>" />

              </div>

              <div class="span4">

                <label>City</label>

                <input type="text" name="city" id="city" class="span12" value="<?php echo $dataProfile['city'];?>" />

              </div>

              <div class="span4">

                <label>Nationality</label>

                <select  id="country" class="input_text" name="country" >

                  <option value="<?php echo $dataProfile['country'];?>" selected="selected"><?php echo $dataProfile['country'];?></option>

                  <?php  include "templates/nationallist.php";?>

                </select>

              </div>

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Opening Date <span class="f_req">*</span></label>

                <input type="text" name="openingdate" id="openingdate" class="span12" value="<?php echo $dataProfile['openingdate'];?>" />

              </div>

              <div class="span4">

                <label>Billing Date <span class="f_req">*</span></label>

                <input type="text" name="billingdate" id="billingdate" class="span12" value="<?php echo $dataProfile['billingdate'];?>" />

              </div>

              <div class="span4">

                <label>VoterID </label>

                <input type="text" name="voterID" id="voterID" class="span12"  value="<?php echo $dataProfile['voterid'];?>"/>

              </div>

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Blood Group</label>

                <input type="text" name="bloodgroup" id="bloodgroup" class="span12" value="<?php echo $dataProfile['bloodgroup'];?>" />

              </div>

			  <div class="span4">

                <label>Reseller</label>

                <SELECT class="input_text" name="reseller" id="reseller">

                  <OPTION SELECTED VALUE="<?php echo $dataProfile['resellerID'];?>"><?php echo $dataProfile['reseller'];?></OPTION>

                  <?php

						if($resellerType)

						{

						   while($mydata=mysqli_fetch_row($resellerType))

							{

							 echo "<option value='$mydata[0]'>$mydata[1]</option>";

							}

						}	

							?>

                </SELECT>

              </div>

              <div class="span4">

                <label>Package <span class="f_req">*</span></label>

                <SELECT class="input_text" name="package" id="package">

                  <OPTION SELECTED VALUE="<?php echo $dataProfile['packageID'];?>"><?php echo $dataProfile['package'];?></OPTION>

                  <?php

						if($packageType)

						{

						   while($mydata=mysqli_fetch_row($packageType))

							{

							 echo "<option value='$mydata[0]'>$mydata[1]</option>";

							}

						}	

							?>

                </SELECT>

              </div>

              

            </div>

          </div>

		  <div class="formSep">

            <div class="row-fluid">



              <div class="span4">

                <label>Reference</label>

                <input type="text" name="reference" id="reference" class="span12" />

              </div>

            </div>

          </div>

          <h4 class="heading">Office Only</h4>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>IP </label>

                <input type="text" name="IP" id="IP" class="span12"  value="<?php echo $dataProfile['IP'];?>"/>

              </div>

              <div class="span4">

                <label>MAC</label>

                <input type="text" name="MAC" id="MAC" class="span12" value="<?php echo $dataProfile['MAC'];?>" />

              </div>

             

            </div>

          </div>

          <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Installation Charge</label>

                <input type="text" name="installamount" id="installamount" class="span12" value="<?php echo $dataProfile['installamount'];?>" />

              </div>

			   <div class="span4">

                <label>Monthly Charge</label>

                <input type="text" name="amount" id="amount" class="span12" value="<?php echo $dataProfile['amount'];?>" />

              </div>

            </div>

          </div>

		  <div class="formSep">

            <div class="row-fluid">

              <div class="span4">

                <label>Username <span class="f_req">*</span></label>

                <input type="text" name="username" id="username" class="span12" value="<?php echo $dataProfile['username'];?>" />

              </div>

              <div class="span4">

                <label>Password <span class="f_req">*</span></label>

                <input type="password" name="password"  id="password"  class="span12"  value="<?php echo $dataProfile['password'];?>"/>

              </div>

            </div>

          </div>

          <div class="form-actions">

            <input class="btn btn-inverse" name="submit" type="submit" value="Save Form" />

            <button class="btn">Cancel</button>

          </div>

        </form>

      </div>

    </div>

  </div>

</div>

