<?
//***************************************************
// http://www.scriptindonesia.com
// Solusi Hemat Script Bisnis Online Anda
// Menerima Jasa Pembuatan Website & Template Website
//***************************************************
?>
<?
//Edit Script AW 20160221
//if (session_is_registered("valid_admin")) {
  if (isset($_SESSION['valid_admin'])) {
?>

<script type="text/javascript">

<!--

function confirmation(noid) {

	var answer = confirm("Are You sure to delete this testimonial ?")

	if (answer){

		//alert("Bye bye!")

		window.location = "?m=testimonial&page=delete&no=" + noid;

		

	}

	

}

//-->

</script>
<style type="text/css">
<!--
.style1 {
	font-size: 10px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #FF0000;
}
-->
</style>


<h2><img src="images/icon-48-user.png" width="48" height="48" align="absmiddle" /> Testimonial Manager </h2>


<?

switch($page) {

	default :

?>	

<?

//---pagination----------------
$limit = '50';        // How many results should be shown at a time
$scroll = '0';        // Do you want the scroll function to be on (1 = YES, 2 = NO)
$scrollnumber = '50'; // How many elements to the record bar are shown at a time when the scroll function is on
//-------------pagination--------------

if (!isset ($_GET['show'])) {
	$display = 1;
} else {
	$display = $_GET['show'];
}
$start = (($display * $limit) - $limit);

//if($uidm == 001) {
//$db->select("*", "member", $kat);

//	$numrows = $db->count_records("testimonial", $filter);	
//	$db->select("no, userid, nama, kota, testimoni, foto, published, tgl", "testimonial", "", "tgl DESC");

  //AW 20140208 Edit
if($kat > 0 or !$kat) {
	$order = "tgl desc";
}
if($kat == "") {  
	$numrows = $db->count_records("member", "hubungan<>''");
	$db->select("id, username, nama, email, kota, hubungan, foto, tgl", "member", "hubungan <> '' and username <> 'member'", $order, "", "", "$start, $limit"); //AW
}
$sel = "selected";
?>


<table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#bfd6ed">
  <tr>
    <td width="100%" height="2" bgcolor="#cccccc">
    </td>
  </tr>
</table>

<table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="#bfd6ed">
  <tr>
    <td width="100%" height="2" bgcolor="#cccccc">
        <!-- ------------------------------------- -->
        <div id="menu_button2" align="center">
            <strong><?= $db->config("bank2") ?></strong>
        </div>
        <!-- ------------------------------------- -->
    </td>
  </tr>
</table>

<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
    <td height="30" bgcolor="#8c759a"><div align="center"><span class="title">&nbsp;&nbsp;<strong><u>List Testimoni Member</u></strong><u></u></span></div></td>
  </tr>
  <tr>
    <td width="956" bgcolor="#EF9400"><img src="../images/px1.gif" width="1" height="1" alt="" border="0"></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="5">
<!--
  <tr>
    <td colspan="12" align="center" style="padding:0"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding:0; margin:0">
      <tr>
        <td><form action="" method="post" name="form1" id="form1" style="margin:0; padding:0">
          <label> Katagori :
            <select name="select" onchange="location =  this.options[this.selectedIndex].value" class="form">
            <option value="?m=testimonial" selected="selected" <? echo $pilih; ?>>Semua Testimonial</option>
          </select>
          </label>&nbsp;&nbsp;
        Total: <b><?= $numrows; ?></b> testimonial
        </form></td>
        <td><form id="form2" name="form2" method="post" action="?m=testimonial&amp;kat=2" style="margin:0; padding:0">
          <label>
            Cari Testimonial :
            <input name="keywrd" type="text" id="keywrd" placeholder="username,nama,email,testimonial" />
            </label>
          <label>
          <input type="submit" name="Submit" value="CARI" />
          </label>
        </form>        </td>
      </tr>
    </table></td>
  </tr>
-->
  <tr class="tbl_header">
    <td width="4%" align="center">#</td>
    <td width="10%" align="center">Username</td>
    <td width="16%" align="center">Nama Lengkap</td>
    <td width="20%" align="center">Email</td>
    <td width="50%" align="center">Testimonial</td>
  </tr>

<?
$j=$db->num_rows();
for($i=0;$i<$j;$i++) {
//	$nom = $i + 1;
	$nom = $i + 1 + $start; //AW
	$lid = $i - 1;
	if(is_odd($i) == 0) {
		$class = "tblrow_ganjil";
	} else {
		$class = "tblrow_genap";
	} 	

	if($db->result($i, "published") > 0) {
		$img = "<a href='?m=testimonial&page=publish&pub=0&no=".$db->result($i, "no")."'><img src='images/tick.png' border=0 title='Click to Unpublish'></a>";
	} else {
		$img = "<a href='?m=testimonial&page=publish&pub=1&no=".$db->result($i, "no")."'><img src='images/publish_x.png' border=0 title='Click to Publish'></a>";
	} 	
?>

 

  <tr class="<?= $class; ?>">
    <td width="4%"><?= $nom; ?> </td>
    <td width="10%"><a href="?m=member&page=addnew&edit=1&mid=<?= $db->result($i, "username"); ?>"><?= $db->result($i, "username"); ?></a></td>
    <td width="16%"><a href="?m=member&page=addnew&edit=1&mid=<?= $db->result($i, "username"); ?>"><?= $db->result($i, "nama"); ?></a></td>
    <td width="20%"><?= $db->result($i, "email"); ?></td>
    <td width="50%"><a href="?m=member&page=addnew&edit=1&mid=<?= $db->result($i, "username"); ?>"><?= substr($db->result($i, "hubungan"),0,70); ?>...</td></a></td>
  </tr>

<?
	}
?>	  
</table>

<br />

<table width="100%" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td align="center">

     <?php
//}
//

$paging = ceil ($numrows / $limit);

// Display the navigation
if ($display > 1) {
	$previous = $display - 1;
?>

  <a href="?m=testimonial&kat=<?= $kat; ?>&show=1" style="font-size:10px; color:#0000CC"><< Awal </a> | <a href="?m=testimonial&kat=<?= $kat; ?>&show=<?= $previous; ?>" style="font-size:10px; color:#0000CC">< Sebelumnya </a> |

  <?php
}

if ($numrows != $limit) {
	if ($scroll == 1) {
		if ($paging > $scrollnumber) {
			$first = $display;
			$last = ($scrollnumber - 1) + $display;
		}
	} else {

		$first = 1;
		$last = $paging;
	}

	if ($last > $paging ) {
		$first = $paging - ($scrollnumber - 1);
		$last = $paging;
	}

	for ($i = $first;$i <= $last;$i++){
		if ($display == $i) {
?>

[ <b>

<?= $i ?>

</b> ]

<?php			
		} else {
?>

[ <a href="?m=testimonial&kat=<?= $kat; ?>&show=<?= $i; ?>" style="font-size:10px; color:#0000CC">

<?= $i; ?>

</a> ]

<?php
		}
	}
}



if ($display < $paging) {



	$next = $display + 1;

	

?>

| <a href="?m=testimonial&kat=<?= $kat; ?>&show=<?= $next; ?>" style="font-size:10px; color:#0000CC">Selanjutnya ></a> | <a href="?m=testimonial&kat=<?= $kat; ?>&show=<?= $paging; ?>" style="font-size:10px; color:#0000CC">Terakhir >></a>

<?php



}

//

?>

    </td>

  </tr>

</table>

<p>&nbsp;</p>

<?

	break;

	case addnew :

	if($edit > 0) {

		$db->select("no, userid, nama, kota, testimoni, foto, published, tgl", "testimonial", "no=$no");

		$foto = $db->result(0, "foto");

		$userid = $db->result(0, "userid");

		$kota = $db->result(0, "kota");

		

		$testi = $db->result(0, "testimoni");

		$nama = $db->result(0, "nama");

	}	

	

?>

<form action="?m=testimonial&amp;page=submit" method="post" enctype="multipart/form-data">

  <div align="center">

    <center>

      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="70%" id="AutoNumber1" bordercolor="#EDEDE9">

        <tr class="tbl_header">

          <td width="100%" align="center"><?

		  if($act == 1 or $act) {

?>

<div id="notice"><img src="images/notice-info.png" width="29" height="29" align="absmiddle" />Data telah berhasil diupdate ! </div>

	<?

	}

	?>

		  

		  

		  <b><font face="Arial">UPDATE 

            DATA TESTIMONIAL MEMBER DI SINI</font></b></td>

        </tr>

        <tr>

          <td width="100%" style="border-style: none; border-width: medium"><div align="center">

              <table width="80%" border="0" cellspacing="0" cellpadding="1">
                <tr>

                <td width="38%" align="right">Username  : </td>

                <td width="62%"><input name="userid" type="text" class="form" id="userid" value="<?= $userid; ?>" size="20" />

                    <input name="no" type="hidden" class="form" id="no" value="<?= $no; ?>" size="10" />

                    <input name="edit" type="hidden" class="form" id="edit" value="<?= $edit; ?>" size="10" />

                  <label></label></td>

              </tr>

              <tr>

                <td align="right">Nama : </td>

                <td><input name="nama" type="text" class="form" id="nama" value="<?= $nama; ?>" size="40" /></td>

              </tr>

              <tr>

                <td align="right">Kota : </td>

                <td><input name="kota" type="text" class="form" id="kota" value="<?= $kota; ?>" size="40" /></td>

              </tr>

              <tr>

                <td align="right">Foto : </td>

                <td><label>

                  <?

		  	if($foto <> "") {

		?>

                  <img src="../member/images/<?= $foto; ?>" alt="<?= $nama; ?>" /><br />

                  <?

		 }

		 ?>

                  <input name="img1" type="file" id="img1" size="40" class="form" />

                  </label>

                    <input name="foto" type="hidden" class="form" id="foto" value="<?= $foto; ?>" size="12" /></td>

              </tr>

              <tr>

                <td align="right" valign="top">Testimoni  : </td>

                <td valign="top"><textarea name="testimoni" cols="50" rows="8" class="form" id="testimoni"><?= $testi; ?></textarea></td>

              </tr>

              <tr>

                <td align="right">&nbsp;</td>

                <td><label>

                    <input name="Submit" type="submit" class="button"  value="SAVE" />

</label>

                  <label>

                  <input type="button" name="cancel" id="cancel" value="CANCEL" onclick="javascript:history.go(-1)" class="cancelbutton" />

                  </label></td>

              </tr>

            </table>

              <p class="style1">&nbsp;</p>
            </div></td>

        </tr>

      </table>

    </center>

  </div>

</form>

<?	

	break;

	

	case submit :

	//---------upload foto
	function getFileExtension($filename){
  return substr($filename, strrpos($filename, '.'));
}
if(getFileExtension($img1_name) == ".php" or getFileExtension($img1_name) == ".PHP" or getFileExtension($img1_name) == ".php4" or getFileExtension($img1_name) == ".PHP4" or getFileExtension($img1_name) == ".php5" or getFileExtension($img1_name) == ".PHP5" or getFileExtension($img1_name) == ".exe" or getFileExtension($img1_name) == ".EXE "or getFileExtension($img1_name) == ".htm" or getFileExtension($img1_name) == ".HTM" or getFileExtension($img1_name) == ".html" or getFileExtension($img1_name) == ".HTML" or getFileExtension($img1_name) == ".bat" or getFileExtension($img1_name) == ".BAT") {
		echo "<p>&nbsp;</p><p align=center style='color:red'><b>File harus berupa file image (jpg, gif atau png)</b></p>";
		
	} else {

		if($img1 <> "") {

			$foto = $img1_name;

			$file = "../member/images/$img1_name";

			@copy("$img1" , $file);

			//$ukr2=getimagesize("../images/$img1_name");

					//	$w2=$ukr2[0];

					//	$h2=$ukr2[1];

		} else {

			$foto = $foto2;

		}	

		//$nama = $db->dataku("nama", $userid);

		if($edit > 0) {

				$db->update("testimonial", "testimoni='$testimoni', nama='$nama', userid='$userid',  foto='$foto', kota='$kota'", "no='$no'");

				echo "<meta http-equiv='refresh' content='0;URL=?m=testimonial&page=addnew&act=1&no=$no&edit=1'>";

			} else {

				$db->insert("testimonial", "", "'', '$userid', '$nama', '$kota', '$testimoni', '$foto', '$clientdate', 1");

				

				echo "<meta http-equiv='refresh' content='0;URL=?m=testimonial'>";

			}
			}



		break;

		

		case publish :

		$db->update("testimonial", "published='$pub'", "no='$no'");

		echo "<meta http-equiv='refresh' content='0;URL=?m=testimonial'>";

	break;

	case delete :

		//echo "delete no $no";

		$db->delete("testimonial", "no=$no");

		echo "<meta http-equiv='refresh' content='0;URL=?m=testimonial'>";

	break;	

}		

?>
<?
} else {
echo "<meta http-equiv=\"refresh\" content=\"1; url=illegal.html\">";
}
?>