<?php include('header.php');?>
<?php include('sidebar.php');?>
 
<?php
$maintitle=AL_CHARITYREQUEST;
$page="charity.php";
$table="tbl_charity";
$field_id="charityid";
$mode=$_REQUEST['mode'];
$content_id=$_REQUEST['contentid'];
if(isset($_REQUEST['start'])){
$start=$_REQUEST['start']-1;
}
else {
$start=0;
}
?>
<?php
 
if(isset($_REQUEST['submit'])=="submit"){ 
$dataexist=array();
$required = array();
$values = $_POST;
unset($values['submit']);
unset($values['mode']);

$userid=array("user_id"=>$user_id);
$values=array_merge($values,$userid);
$image=$helper->image_upload($_FILES['frm_filename'],"news");
$photo=array("image"=>$image);
if($photo!=""){
//$values=array_merge($values,$photo);
}

if($_REQUEST['mode']=="edit"){
$message=$helper->update($table, $values,array($field_id=>$_REQUEST['contentid']),$required);
}

}
?>

<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1><?php echo $maintitle;?></h1>
      <ol class="breadcrumb">
        <li><a href="dashboard.php"><i class="fa fa-dashboard"></i> <?php echo AL_DASHBOARD;?></a></li>
        <li class="active"><?php echo $maintitle;?></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
    <?php
	if($mode=="add" || $mode=="edit"){ 
	?>
     <div class="row">
 <!-- Add / Edit / Delete --> 
          <div class="col-sm-12"> 
          <div class="box box-success">
         <div class="box-header">
              <i class="fa fa-building-o"></i>
              <h3 class="box-title"><?php echo $maintitle;?></h3>
              <div class="box-tools pull-right">
                <div class="btn-group">
                <a href="<?php echo $page;?>"><button class="btn btn-danger btn-flat">&nbsp;<?php echo AL_LISTALL;?> <?php echo $maintitle;?></button></a>
                   
                </div>
              </div>
            </div> 
            </div> 
            </div>

 <!-- Add / Edit / Delete --> 
<?php
if($mode=="edit"){
$contentdetails=$helper->select($table,"*",array($field_id=>$_REQUEST['contentid']));
}
?>

     <div class="col-md-6">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"><?php echo AL_PERSONALDETAILS;?></h3>
            </div>
            
            
            <div class="nav-tabs-custom">
           
             <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
              <div class="box-body">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_NAME;?></label>

                  <div class="col-sm-6">
                  <?php echo $contentdetails[0]['firstname']." ".$contentdetails[0]['lastname'] ;?>
                   </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_EMAIL;?></label>
                  <div class="col-sm-6">
                  <?php echo $contentdetails[0]['email'];?>
                   </div>
                </div>
                   
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_PHONE;?> </label>

                  <div class="col-sm-6">
                  <?php echo $contentdetails[0]['phone'];?>
                   </div>
                </div>
                
                <div class="form-group">
                <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_FAX;?></label>
				<div class="col-sm-6">
                <?php echo $contentdetails[0]['fax'];?>
                                    
                </div>
                <!-- /.input group -->
              </div>
                  <div class="form-group">
                <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_ADDRESS;?></label>
				<div class="col-sm-6">
                <?php echo $contentdetails[0]['address'];?>
                </div>
              </div>
            <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_CITY;?></label>

                  <div class="col-sm-6">
                    <?php echo $contentdetails[0]['city'];?>
                  </div>
                </div>
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_COUNTRY;?></label>

                  <div class="col-sm-6">
                       <?php
                  $mycountry= $helper->select("tbl_country","country",array("countryid"=>$contentdetails[0]['country']));
				  ?>
                  <?php echo $mycountry[0]['country'];?>
                   </div>
                </div> 
             
            </div>
            <!-- /.tab-content -->
            </form>
          </div>
          </div>
         
        </div>
        <div class="col-md-6">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"><?php echo AL_CHARITYDETAILS;?></h3>
            </div>
            
            
            <div class="nav-tabs-custom">
           
             <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
              <div class="box-body">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_CHARITYNAME;?></label>

                  <div class="col-sm-6">
                  <?php echo $contentdetails[0]['charityname'];?>
                   </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_CHARITYADDRESS;?></label>
                  <div class="col-sm-6">
                  <?php echo $contentdetails[0]['charityaddress'];?>
                   </div>
                </div>
                   
                 <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_CHARITYOBJECTIVES;?> </label>

                  <div class="col-sm-6">
                  <?php echo $contentdetails[0]['outline'];?>
                   </div>
                </div>
                
                <div class="form-group">
                <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_LOCATION;?></label>
				<div class="col-sm-6">
                <?php echo $contentdetails[0]['location'];?>
                                    
                </div>
                <!-- /.input group -->
              </div>
                  <div class="form-group">
                <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_PARTICIPANTS;?></label>
				<div class="col-sm-6">
                <?php echo $contentdetails[0]['participants'];?>
                </div>
              </div>
            <div class="form-group">
                  <label for="inputEmail3" class="col-sm-3 control-label"><?php echo AL_DATEOFEVENT;?></label>

                  <div class="col-sm-6">
                    <?php echo $contentdetails[0]['event date'];?>
                  </div>
                </div>
                
             
            </div>
            <!-- /.tab-content -->
            </form>
          </div>
          </div>
         
        </div>
        <!-- Managers Comments-->
        <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"><?php echo AL_MANAGERSCOMMENTS;?></h3>
            </div>
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-success btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
            
            <div class="nav-tabs-custom">
           
             <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
             <input type="hidden" name="mode" value="edit"/>
              <div class="box-body">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_COMMENTS;?></label>

                  <div class="col-sm-6">
                  <textarea name="comments" value="" class="form-control" placeholder="Comments" required> <?php echo $contentdetails[0]['comments'];?></textarea>
                   </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_STATUS;?></label>
                  <div class="col-sm-4">
                  <select name="status" class="form-control">
                  <option <?php if($contentdetails[0]['status']==0){echo "selected";}?> value="0"><?php echo AL_PENDING;?></option>
                  <option <?php if($contentdetails[0]['status']==2){echo "selected";}?> value="2"><?php echo AL_DECLINED;?></option>
                  <option value="1" <?php if($contentdetails[0]['status']==1){echo "selected";}?>><?php echo AL_APPROVED;?></option>
                  <option value="3" <?php if($contentdetails[0]['status']==3){echo "selected";}?>><?php echo AL_PROCESSED;?></option>
                  </select>
                   </div>
                </div>
                <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" name="submit" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-left"/>
              </div>
             
            </div>
            <!-- /.tab-content -->
            </form>
          </div>
          </div>
         
        </div>
        <!--End of Managers Comments-->
        <?php
		if($contentdetails[0]['status']==1 || $contentdetails[0]['status']==3){
	    ?>
        <!-- Accounts Comments-->
        <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="box box-info">
            <div class="box-header with-border">
              <h3 class="box-title"><?php echo AL_FORACCOUNTANTS;?></h3>
            </div>
            
            
            <div class="nav-tabs-custom">
           
             <form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
             <input type="hidden" name="mode" value="edit"/>
              <div class="box-body">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_COMMENTS;?></label>

                  <div class="col-sm-6">
                  <textarea name="accountantcomment" value="" class="form-control" placeholder="Comment" required></textarea>
                   </div>
                </div>
                <div class="box-body">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_AMOUNTOFFERED;?></label>
                  <div class="col-sm-6">
                  <input type="text" name="amount" value="" class="form-control" placeholder="Amount"/>
                   </div>
                </div>
                 <div class="box-body">
                  <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_CHEQUEDETAILS;?></label>
                  <div class="col-sm-6">
                  <input type="text" name="checkdetails" value="" class="form-control" placeholder="Check Details"/>
                   </div>
                </div>
                <div class="form-group">
                  <label for="inputEmail3" class="col-sm-4 control-label"><?php echo AL_STATUS;?></label>
                  <div class="col-sm-4">
                  <select name="status" class="form-control">
                  <option <?php if($contentdetails[0]['status']==1){echo "selected";}?> value="1"><?php echo AL_APPROVED;?></option>
                  <option <?php if($contentdetails[0]['status']==3){echo "selected";}?> value="3"><?php echo AL_PROCESSED;?></option>
                  </select>
                   </div>
                </div>
                <div class="box-footer">
                <button type="reset" class="btn btn-default"><?php echo AL_CANCEL;?></button>
                <input type="submit" name="submit" value="<?php echo AL_SUBMIT;?>" class="btn btn-info pull-left"/>
              </div>
             
            </div>
            <!-- /.tab-content -->
            </form>
          </div>
          </div>
         
        </div>
        <?php
		}
		?>
        <!--End of Managers Comments-->
 
        </div>
        <?php
	    }
		else {
	    ?>
        <?php
		if($mode=="delete"){
			 $message=$helper->delete($table, array($field_id=>$_REQUEST['contentid']));
		}
		?>
          <?php
		if($mode=="approve"){
			$helper->update($table, array("status"=>1),array($field_id=>$_REQUEST['contentid']), array());
		}
		?>
         <?php
		if($mode=="pending"){
			$helper->update($table, array("status"=>2),array($field_id=>$_REQUEST['contentid']), array());
		}
		?>
        <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <i class="fa fa-building-o"></i>

              <h3 class="box-title"><?php echo $maintitle;?></h3>

              <div class="box-tools pull-right" data-toggle="tooltip" title="Add <?php echo $maintitle;?>">
                <div class="btn-group">
               <?php /*?> <a href="<?php echo $page;?>?mode=add"><button class="btn btn-danger btn-flat"><i class="glyphicon  glyphicon-plus"></i>&nbsp;Add New <?php echo $maintitle;?></button></a><?php */?>
                   
                </div>
              </div>
            </div>
            <?php
			$listtypes=$helper->selectlimit($table,"*",array(),$start,$limit);			 
			?>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
            <?php
			if($message!=""){
			?>
            <button class="btn btn-block btn-danger btn-flat" type="button"><?php echo $message['message'];?></button>
			<?php	
			}
			?>
              <table class="table table-hover">
                <tr>
                  <th><?php echo AL_SERIALNO;?></th>
                  <th><?php echo AL_CHARITYNAME;?></th>
                  <th><?php echo AL_CHARITYOBJECTIVES;?></th>
                  <th><?php echo AL_NAME;?></th>
                   <th><?php echo AL_EMAIL;?></th>
                   <th><?php echo AL_PHONE;?></th>
                  <th><?php echo AL_STATUS;?></th>
                  <th><?php echo AL_ACTION;?></th>
                </tr>
                <?php
				$i=($start*$limit)+1;
				foreach($listtypes as $type){
				?>
                 <?php
				  if($_REQUEST['start']>0){
					  $limitpage=$_REQUEST['start'];
				  }
				  else {
					  $limitpage=1;
				  }
				 
                    
				  ?>
                <tr>
                  <td><?php echo $i;?></td>
                  
                  <td><?php echo $type['charityname'];?></td>
                   <td><?php echo $type['outline'];?></td>
                  <td><?php echo $type['firstname']." ".$type['lastname'];?></td>
                  <td><?php echo $type['email'];?></td>
                   <td><?php echo $type['phone'];?></td>
                  <td>	  
                    <?php
                   
				  if($type['status']==1){
				  ?>
<a href=""><span class="label label-success"><?php echo AL_APPROVED;?></span></a>
                  <?php
				  }
				  else if($type['status']==2){
				  ?>
				  <a href="#"><span class="label label-warning"><?php echo AL_DECLINED;?></span></a>
                  <?php		  }
                                  else if($type['status']==3){
				  ?>
				  <a href=""><span class="label label-primary"><?php echo AL_PROCESSED;?></span></a>
                  <?php		  }
                                  else{
				  ?>
				  <a href=""><span class="label label-danger"><?php echo AL_PENDING;?></span></a>
                  <?php
				  }
				  ?>
                      
                      
                  </td>
                  <td>
                  <a href="<?php echo $site_url;?><?php echo $page;?>?mode=edit&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>"><span class="label label-primary"><i class="fa fa-edit"></i> <?php echo AL_EDIT;?></span></a>
                  <?php
				  if($valexist==0 && $valexist==0){
				  ?>
                   <a href="<?php echo $site_url;?><?php echo $page;?>?mode=delete&contentid=<?php echo $type[$field_id];?>&start=<?php echo $limitpage;?>" onclick="return getConfirmation()"><span class="label label-danger"><i class="fa fa-times"></i> <?php echo AL_DELETE;?></span></a>
                   <?php
				  }
				  ?>
                   </td>
                </tr>
                 
                <?php
				$i=$i+1;
				}
				?>
                
                
              </table>
              <?php
			   $counter_list= $helper->countofdata($table,array(),$limit,array("status"=>"ASC"));
			  include('pagination/pagination.php');
			  ?>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
      <?php
		}
		?>

    </section>
    <!-- /.content -->
  </div>
<?php include('footer.php');  ?>