
<?php
include("../includes/site_config.php");
include('../session_handler.inc');
include('../error.php');
//include('imagesizer.php');
include('paginate.php');
include('../message.php');
include('../includes/functions.php');
include("../includes/tab_functions.js");
include("../ajax.js");
include('../lib/lib.Functions.php');
include_once __INCLUDE_CLASS_PATH."/class.Audio.php";
$audio = new Audio(); 
include_once __INCLUDE_CLASS_PATH."/class.DB.php"; 
$db = new DB();

$mode=$_GET['mode'];
$option_manager = new OptionManager();
$audcount=$option_manager->GetValue('audio_count');
$CONST_MAIL=$option_manager->GetValue('mail');



$Sess_UserId = $_SESSION['Sess_UserId'];
$Sess_UserName = $_SESSION['Sess_UserName'];

# select advert data

$result = mysql_query("SELECT * FROM adverts WHERE adv_userid=$Sess_UserId",$link);

$TOTAL = mysql_num_rows($result);

# if nothing is returned then show error otherwise get data

if ($TOTAL < 1) {

    $error_message=PRGPICADMIN_ERROR1;

    error_page($error_message,GENERAL_USER_ERROR);

}

if ($mode=='amend') {



        if ($Sess_UserName == '$Sess_UserName') {

            restrict_demo();

        }



    //$chkRemoveaud=formGet('chkRemoveaud');
$chkRemoveaud=form_get('chkRemoveaud');

    //$chkPrivateaud=formGet('chkPrivateaud');
$appAud=form_get('appAud');

if ($chkRemoveaud) {
    //if (count($chkRemoveaud)) {

        //foreach ( $chkRemoveaud as $key=>$value) {
$quePic=mysql_fetch_object(mysql_query("SELECT * from audios LEFT JOIN members on(aud_userid=mem_userid) where aud_id='$chkRemoveaud'"));
            $audio->InitById($chkRemoveaud);

            $audio->DeleteAud();
send_mail ("$quePic->mem_email", "$CONST_MAIL", "$CONST_COMPANY ".AUD_UNAPR, MAIL_UNAPPROVEDAUD,$type,"ON");

     //   }

    }

    $audio->ClearPrivate($Sess_UserId);

	 if ($appAud) {
   // if (count($chkPrivateaud)) {

       // foreach ( $chkPrivateaud as $key=>$value) {

            $audio->InitById($appAud);

            $audio->ApproveAud();
			
			$quePic=mysql_fetch_object(mysql_query("SELECT * from audios LEFT JOIN members on(aud_userid=mem_userid) where aud_id='$appAud'"));	
send_mail ("$quePic->mem_email", "$CONST_MAIL", "$CONST_COMPANY ".AUD_APR, MAIL_APPROVEDAUD,$type,"ON");

        //}

    }

	//include("generate_profile.php");

}

$aAudios = $audio->GetListByAudioApp();

$resultaud = count($aAudios);

$area = 'member';

?>

<?php include("include/header.php"); ?>

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);
  return false;
}
//-->





</script>

<?php include('approve_menu.php'); ?>
<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;Approve Audio</div></div>
<div class="clear"></div>
<div class="admin-page">

<table width="680" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="0" cellpadding="0">
 <tr>

    <td>  
	<!-------------------------------------------->
	<table width="680"  border="0" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>"><tr><td>
	<? if($resultaud < 1){?>
<table>
<tr > <td>&nbsp;</td>
 <td  align="left"> <font color="#CC0000" size="+2">Nothing To Approve!</font></td>
 <td align="center"></td>
 </tr></table>
<? }?>
     

          <?php

   

       

        
		$i=0;
        while ($indx < $resultaud) {

            $indx++;

            $sql_array = array_shift($aAudios);

                $aud_private="";

                if($sql_array->aud_private=='Y') $aud_private="checked";

                $aud_info = $sql_array->getInfo('small');

if(($i%6)==0)
	{
	print "<br style=clear:both>";
}

                 print("

                       
<table align=left><tr>
                        <td align='center'>
						
						<input type='image' src='$CONST_IMAGE_ROOT/audio_latest.jpg' value='$sql_array->aud_id' onClick='toggle_audApp(this.value);' name='My Audio' width='100' height='100'>					
									
						");?>
						<br />	<?=$sql_array->title?>
						<br><a href="<?=$CONST_LINK_ROOT ?>/admin/approve_audio.php?chkRemoveaud=<?=$sql_array->aud_id?>&mode=amend&type=aa" onclick="javascript:return confirm('Are you sure want to delete')">Delete</a>|
						 <? print("<a href=\"$CONST_LINK_ROOT/admin/approve_audio.php?appAud=$sql_array->aud_id&type=aa&mode=amend\">Approve</a>
<input type='hidden' name='aud_exists[]' value=$sql_array->aud_id></td></tr></table>

                       

                  ");

      $i++;  }
print "<br style-clear:both>";?>
</td></tr></table>

</table>

</div><div class="admin-page-bottom"></div></div>
<br /><br />
<!--Approve Audios Code Starts here-->
<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;<?=APPROVED_AUDS?></div></div>
<div class="clear"></div>
<div class="admin-page">


<table width="680"  border="0" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>">
<tr><td>
	
      

<?php

 $quer=  "
            SELECT 	*
                      FROM audios
           	                    WHERE approved = '1'
            			                    ORDER BY aud_id DESC
        ";

       
$record_per_page='20';

$pager = new PS_Pagination($link,$quer,$record_per_page,5);
$rs = $pager->paginate();

$indx=0;


echo "<table align=left><tr>
                       
";
$j=0;
while($sql_app=mysql_fetch_object($rs)){

       
		
        //while ($indx < $resultaud) {

            $indx++;

           // $sql_app = array_shift($aAudios);

                $aud_private="";

                if($sql_app->aud_private=='Y') $aud_private="checked";

                //$aud_info = $sql_app->getInfo('small');

if(($j%5)==0)
	{
	print "<tr>";
}
?>
                
                       
						
						 <td align='center'><input type='image' src="<?=$CONST_LINK_ROOT?>/templates/default/images/audio_latest.jpg" value='<?=$sql_app->aud_id?>' onClick='javascript: return toggle_audApp(this.value);' name='My Audio' width='100' height='100'><br />	<?=$sql_app->title?>				
									
						
						
						<br><? if($DEMO==false){?><a href="<?=$CONST_LINK_ROOT?>/admin/approve_audio.php?chkRemoveaud=<?=$sql_app->aud_id?>&mode=amend&type=aa" onclick="javascript:return confirm('Are you sure want to delete')">Delete</a><? }?>
						 <? print("<input type='hidden' name='aud_exists[]' value='$sql_app->aud_id'></td>

                       

                  ");

      $j++;  }
	  echo "</tr></table>";
print "<br style-clear:both>";?>
</td></tr>
<tr align="right"><td><? echo $pager->renderNext(); ?></td></tr>
</table>


<!--Code Ends here-->
<table><tr><td>
<div id="audio_div"  align="center" style="font-size: 10px;font-weight: bold;color:#0066FF"> </div>
</td></tr></table>



</div><div class="admin-page-bottom"></div></div>



<?php include("include/footer.php"); ?>