
	<?php
	
	/*
	Hezecom Email Solution
	Author: Hezecom Technologies (http://hezecom.com) info@hezecom.net
	COPYRIGHT 2014 ALL RIGHTS RESERVED
	
	You must have purchased a valid license from CodeCanyon.com in order to have 
	access this file.

	You may only use this file according to the respective licensing terms 
	you agreed to when purchasing this item.
	*/
	
	if(!defined('VALID_DIR')) die('You are not allowed to execute this file directly');
	
	include(APP_FOLDER.'/models/objects/mailusers.php');
	
	class mailusers_controller {
	public $mailusers_model;
	
	public function __construct()  
    {  
        $result = $this->mailusers_model = new mailusers_model();
    } 
	
	public function invoke_mailusers()
	{
	
	//SELECT ALL //////////////////////////////////	
	if(get('do')=='viewall'){
	if(PAGINATION_TYPE=='Normal'){
	$result = $this->mailusers_model->SelectAll(RECORD_PER_PAGE);
	//Accept get url  e.g (index.php?id=1&cat=2...)
	$paging = pagination($this->mailusers_model->CountRow(),RECORD_PER_PAGE,''.H_ADMIN.'&view=mailusers&do=viewall');
	}else{
	$result = $this->mailusers_model->SelectAll();	
	}
	include(APP_FOLDER.'/views/admin/mailusers/View.php');
	}
	
	
	//EXPORT ////////////////////////////////////////////////////	
	if(get('do')=='export'){
	$result = $this->mailusers_model->SelectAll();
	include(APP_FOLDER.'/views/admin/mailusers/Export.php');
	}
	
	//setup ////////////////////////////////////////////////////	
	if(get('do')=='setup'){
	include('config/setup.php');
	}
	
	//ADD //////////////////////////////////////////////////
	elseif(get('do')=='add'){
	if(post('button')){
	//validation example
	//if (post('fieldname')!=''){$errors[] = 'Enter value';} 

	$this->mailusers_model->Insert(post('cfname'),post('clname'),post('cusername'),post('cpassword'),post('cbirthday'),post('cgender'),post('cphone'),post('cemail'),post('clocation'),post('rdate'),post('uid'));
	send_to(''.H_ADMIN.'&view=mailusers&do=viewall&msg=add');
	}
	include(APP_FOLDER.'/views/admin/mailusers/Add.php');
	}
	
	//UPDATE ////////////////////////////////////////////////
	elseif(get('do')=='update'){
	$rows = $this->mailusers_model->SelectOne(get('uid'));
	if(post('button')){
	$this->mailusers_model->Update($rows->user_image,post('cfname'),post('clname'),post('cbirthday'),post('cgender'),post('cphone'),post('cemail'),post('clocation'),post('uid'));
	send_to(''.H_ADMIN.'&view=mailusers&uid='.get('uid').'&do=details&msg=update');
	}
	include(APP_FOLDER.'/views/admin/mailusers/Update.php');
	}
	
	//UPDATE ////////////////////////////////////////////////
	elseif(get('do')=='updatepwd'){
	$rows = $this->mailusers_model->SelectOne(get('uid'));
	include(APP_FOLDER.'/views/admin/mailusers/Update_pwd.php');
	}
	//DETAILS //////////////////////////////////////////////
	elseif(get('do')=='details'){
	$rows = $this->mailusers_model->SelectOne(get('uid'));
	include(APP_FOLDER.'/views/admin/mailusers/Details.php');
	}
	
	//DELETE /////////////////////////////////////////////////
	elseif(get('do')=='delete'){
	$new = new MyCpanel();
	$dfile=get('dfile');
	if(get('uid') and $dfile==''){
	$new->DeleteEmail(get('user'));
	$del = $this->mailusers_model->Delete(get('uid'),''.H_ADMIN.'&view=mailusers&do=viewall&msg=delete');
	}
	elseif(get('uid') and $dfile!='' and get('fdel')==''){
	delete_files(UPLOAD_PATH.get('dfile'));
	delete_files(THUMB_PATH.get('dfile'));
	$new->DeleteEmail(get('user'));
	$del = $this->mailusers_model->Delete(get('uid'),''.H_ADMIN.'&view=mailusers&do=viewall&msg=delete');
	}
	elseif(get('uid') and $dfile!='' and get('fdel')!=''){
	delete_files(UPLOAD_PATH.get('dfile'));
	delete_files(THUMB_PATH.get('dfile'));
	$new->DeleteEmail(get('user'));
	send_to(''.H_ADMIN.'&view=mailusers&uid='.get('uid').'&do=update&msg=delete');
	}
	}
	}//end invoke
	}//end class
	?>
	