<?php
// DISPLAY ALL ERRORS
error_reporting(0);
ini_set('display_errors', 0);
session_start();
ob_start();
require 'setup/config.php';

$LANG =  'cn';
// SET LANGUAGE
if (isset($_GET['lang'])){	
	$_SESSION['HTTP_ACCEPT_LANGUAGE'] = $_GET['lang'];
}  
if (isset($_SESSION['HTTP_ACCEPT_LANGUAGE']) and file_exists('lang/' . $_SESSION['HTTP_ACCEPT_LANGUAGE'] . '.php')) {	
	if((@include 'lang/' . $_SESSION['HTTP_ACCEPT_LANGUAGE'] . '.php') === false){
		echo 'Caught exception: Translate file is wrong';
	}else{
		@include_once('lang/' . $_SESSION['HTTP_ACCEPT_LANGUAGE'] . '.php');
	}
} else {
	if((@include 'lang/' . $LANG . '.php') === false){
		echo 'Caught exception: Translate file is wrong';
	}else{
		@include_once('lang/' . $LANG . '.php');
	}
}

// INI VARs
$found = 0;                     // MARKER HOW MANY HITS FOUND A SEARCH
$done = 0;                     // MARKER HOW MANY ENTRYs ARE DONE
$msg = '';                    // TOAST MESSAGE
$file = 'data/User.json'; // DATA FILE NAME
// LOGIN CHECK
session_start();
$login = check_current_user_login($ARR_USERS, $SALT);
$currentuser = $login['user'];


//var_dump($login);
if ($login['status'] == 200) {
    if($currentuser->gm != '1'){
		header('location: index.php');exit();
	}
} else {
    header('location: login.php');
    exit;
}
/* $sessionname = md5($USER . $SALT);
  if (!@$_SESSION[$sessionname]) {
  header('location: login.php');
  exit;
  } */
// DELETE ENTRY IF DEL LINK IS CLICKED
if (@$_GET['delete_id'] != '') {
    $data = json_decode(file_get_contents($file), true);
    
    foreach ( $data as $key => $r  ){
        if($r['id'] == @$_GET['delete_id']){
            unset($data[$key]);
        }
    }
    
    $convert_array_to_json = array_values($data);
    $write_json = json_encode($convert_array_to_json);
    file_put_contents($file, $write_json);
    /*
    // DELETE TAB USER
    $data = json_decode(file_get_contents('data/Tabs.json'), true);
    
    foreach ( $data as $key => $r  ){
        if($r['iduser'] == @$_GET['delete_id']){
            unset($data[$key]);
        }
    }
    
    $convert_array_to_json = array_values($data);
    $write_json = json_encode($convert_array_to_json);
    file_put_contents('data/Tabs.json', $write_json);
    */
    header('location: user.php?msg=' . $i18n['Entry successfully deleted.']);
    
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['name'] != '' 
    && $_POST['password'] != ''
    && $_POST['role'] != '' && $_POST['location'] != '' ) {
    $receivable = $amount = 0;
        $formdata = array(
        'id' => time()
        , 'name' => $_POST['name']
        //, 'gmail' => $_POST['gmail']
        , 'password' => $_POST['password']
        , 'role' => $_POST['role']
        , 'location' => $_POST['location']
		, 'account' => $_POST['account']
		, 'noti' => $_POST['noti']
                , 'companyinfo' => $_POST['companyinfo']
		, 'accountreadonly' => $_POST['accountreadonly']		
		, 'createbyname' => $currentuser->name
		, 'changedcurrency' => $_POST['changedcurrency']
		, 'chart' => $_POST['chart']
		, 'condition' => $_POST['condition']
		, 'daytoseedata' => $_POST['daytoseedata']
		, 'total' => $_POST['total']
		, 'totalconsignee' => $_POST['totalconsignee']
		, 'totalmonth' => $_POST['totalmonth']
		, 'customer' => $_POST['customer']
		, 'cherry' => $_POST['cherry']
		, 'reminder' => $_POST['reminder']
		, 'end' => $_POST['end']
		, 'borrow' => $_POST['borrow']
		, 'locationreminder' => $_POST['locationreminder']
		, 'filelocation' => $_POST['filelocation']
                , 'mod1' => $_POST['mod1']
                , 'mod2' => $_POST['mod2']
                , 'mod3' => $_POST['mod3']
                , 'mod4' => $_POST['mod4']
                , 'mod5' => $_POST['mod5']
                , 'mod6' => $_POST['mod6']
                , 'mod7' => $_POST['mod7']
                , 'mod8' => $_POST['mod8']
                , 'mod9' => $_POST['mod9']
                , 'mod10' => $_POST['mod10']
                , 'mod11' => $_POST['mod11']
                , 'mod12' => $_POST['mod12']
                , 'mod13' => $_POST['mod13']
                , 'mod14' => $_POST['mod14']
                , 'mod15' => $_POST['mod15']
                , 'mod16' => $_POST['mod16']
                , 'mod17' => $_POST['mod17']
                , 'mod18' => $_POST['mod18']
                , 'mod19' => $_POST['mod19']
                , 'mod20' => $_POST['mod20']
                , 'mod21' => $_POST['mod21']
                , 'mod22' => $_POST['mod22']
                , 'mod23' => $_POST['mod23']
                , 'mod24' => $_POST['mod24']
                , 'mod25' => $_POST['mod25']
                 , 'mod26' => $_POST['mod26']
                  , 'mod27' => $_POST['mod27']
                 , 'mod28' => $_POST['mod28']
                , 'mod29' => $_POST['mod29']
		
    );

    $arr_data = array();
    if (file_exists($file)) {
        $jsondata = file_get_contents($file);
        $arr_data = json_decode($jsondata, true);
    }
    $arr_data[] = $formdata;
   // file_put_contents( 'debug' . time() . '.log', var_export($arr_data, true));
    $jsondata = json_encode($arr_data);
    if (file_put_contents($file, $jsondata)) {
        $msg = $i18n['Data successfully saved!'];
    } else {
        $msg = $i18n['ERROR &mdash; Data not saved!'];
    }
    header('location: user.php?msg=' . $msg);
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $_GET['msg'] = $i18n['All fields are required!'];
}

// CREATE DATA FILE IF NOT EXISTS
if (!is_file($file)) {
    file_put_contents($file, '');
}

// READ DATA
$data = json_decode(file_get_contents($file), true);
$tabs = json_decode(file_get_contents('data/Tabs.json'));
$tabdocfull = $tabdoc = json_decode(file_get_contents('data/TabDoc.json'));

$corresponding = json_decode(file_get_contents('data/Corresponding.json'));
foreach ($corresponding as $r){ 
	$corresponding_id[$r->id] = $r;        
        $corresponding2[ (int) filter_var($r->fullname, FILTER_SANITIZE_NUMBER_INT)] = $r;
}


// HEADER
ob_end_flush();
include 'tpl/header.php';
// FORM FOR NEW ENTRY

if(@$_GET['q'] == ''){
    ?>
        <div class="badge grey lighten-3 hoverable create-user">
            <form action="" method="POST">
                <div class="row">
                    <div class="input-field col s1">
                        <input 
                            value="<?php echo @$_POST['name']; ?>" 
                            id="name" 
                            name="name" 
                            type="text" 
                            class="validate" 
                            maxlength="32" 
                            data-length="32" 
                            required="required"  autocomplete="off"  />
                        <label for="name"><?php echo $i18n['Name']; ?></label>
                       
                    </div>                    
                    <div class="input-field col s1">
                        <input 
                            value="<?php echo @$_POST['password']; ?>" 
                            id="password" 
                            name="password" 
                            type="password" 
                            class="validate" 
                            maxlength="32" 
                            data-length="32" 
                            required="required" autocomplete="off" />
                        <label for="password"><?php echo $i18n['Password']; ?></label>
                      
                    </div>
                    <div class="input-field col s1">
                        <select name="role" id="role">
			<?php if ($currentuser->gm == '1' ) {  ?>    
                            <option value="Manager">Manager</option>
							<option value="Finance">Controller</option>
			<?php } ?>
                            <option value="Operator">Finance</option>
                        </select>
                        <label for="nonumber"><?php echo $i18n['Role']; ?></label>
                        
                    </div>
                    <div class="input-field col s1">
                       <?php if( $currentuser->gm == 1 ){ ?> 
				<select name="location" id="location">
                            		<option value="总公司">总公司</option>
                            		<option value="越南">越南</option>
                            		<option value="中国">中国</option>
									<option value="泰国">泰国</option>
                                                                        <option value="印尼">印尼</option>
                                                                         <option value="马来西亚">马来西亚</option>
                        	</select>
			<?php }else{ ?> 
				<select name="location" id="location">
                            		<option value="<?= $currentuser->location ?>"><?= $currentuser->location ?></option>                            		
                        	</select>
			<?php } ?>
                        <label for="location"><?php echo $i18n['Location']; ?></label>
                        
                    </div>
					<div class="input-field col s3">
					
					
						<select name="account[]" id="account" multiple >
							<?php foreach ( $tabs as $r ){
								if( $currentuser->gm != 1 && $r->iduser != $currentuser->id ) { continue; } 
							?>
								 <option value="<?php echo $r->id ?>"><?php echo $r->name ?></option>';
							<?php }?>
						</select>
						<label for="location">Accounting</label>
                       
					</div>
					<div class="input-field col s3">
						<select name="accountreadonly[]" id="accountreadonly" multiple >
							<?php foreach ( $tabs as $r ){
								if( $currentuser->gm != 1 && $r->iduser != $currentuser->id ) { continue; } 
							?>
								 <option value="<?php echo $r->id ?>"><?php echo $r->name ?></option>';
							<?php }?>
						</select>
						<label for="location">Accounting Readonly</label>
                       
					</div>
					
					<div class="input-field col s1" style="    text-align: right;">
                        <button class="colortoptran btn waves-effect waves-light" type="submit" name="action">
                            <?php echo $i18n['Save']; ?>
                        </button>
                    </div>
                    <div class="input-field col  s1">
                        <a style="    background: #4e4e4e;" class="btn  btn-default waves-effect waves-light" href="./index.php">
                            <?php echo $i18n['Go Back']; ?>
                        </a>
                    </div>
					<div class="input-field col s12" style="    height: 40px;    margin-top: -15px;" >				
					
					<div class="input-field col s1" style="    margin: 0;padding: 0;">
						<select name="filelocation[]" id="filelocation" multiple >
                            <option >----</option> 	
                            <option value="越南">越南</option>
                            <option value="中国">中国</option>
							<option value="泰国">泰国</option>
                        </select>
						<label for="location" style="   top: -9px;    left: 1px;    font-size: 9px;">File Manager</label>
                        <span class="helper-text" data-error="Error" data-success="OK">
                        </span>
					</div>
                                    
                                          
                                           <div class="input-field col s1" style="    margin: 0;" >
						<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="cherry"   name="cherry"  >
						  <span>Modab01任意地址登录</span>
						</label>
					</div>    
                                            
                                            
					
 
                                        <?php 
					$daytoseedata = '';
					if($currentuser->daytoseedata > 0){
						$daytoseedata = $currentuser->daytoseedata;
					}
                                        /*
                                        <select name="daytoseedata" id="daytoseedata">
						<option value="0">Modab02可看日记账天数</option>
						<?php for($d= 1; $d <= 30; $d++){
                                                    if($d != '1' && $d != '7' && $d != '15' && $d != '30'){continue;}
							?><option <?php if($d == $daytoseedata){ echo 'selected'; } ?> value="<?php echo $d; ?>"><?php echo $d; ?></option><?php
						} ?>
					</select>
                                         */
					?>	
					<div class="input-field col s2" style="    margin: 0;" >
					
                                            <input name="daytoseedata" id="daytoseedata" min="0" type="number" value="<?php echo $daytoseedata; ?>"/>
                                            <label for="daytoseedata">Modab02可看日记账天数</label>
					</div>
					
					 <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="companyinfo"   name="companyinfo"  >
						  <span>Modab03公司资料登记?</span>
						</label>
					</div>	    
					<div class="input-field col s1" style="    margin: 0;display:none;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="customer"   name="customer"  >
						  <span>Customer/客户付款方式?</span>
						</label>
					</div>	
                                     	
					 <div class="input-field col s1" style="    width: 93px;        margin-top: -1px;    margin-left: 4px" >
						<select name="locationreminder" id="locationreminder">
                            		<option value="越南">越南</option>
                            		<option value="中国">中国</option>
									<option value="泰国">泰国</option>
                        </select>	
					</div>  
					
					
                                        
                                      	
                                           
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="total"   name="total"  >
						  <span>MOD1余额汇总</span>
						</label>
					</div>	
					<div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="totalconsignee"   name="totalconsignee"  >
						  <span>MOD2财务报表</span>
						</label>
					</div>	
					<div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="totalmonth"   name="totalmonth"  >
						  <span>MOD3账户收支/月</span>
						</label>
					</div>
					<div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod4"   name="mod5"  >
						  <span>MOD4过账余额汇总</span>
						</label>
					</div>     
                                      <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="changedcurrency"   name="changedcurrency"  >
						  <span>MOD5汇率</span>
						</label>
					</div>      
                    </div>
                     <div class="input-field col s12" style="    height: 40px;    margin-top: -7px;" >	
                                         
                                       
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod6"   name="mod6"  >
						  <span>MOD6Consignee</span>
						</label>
					</div> 
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod7"   name="mod7"  >
						  <span>MOD7客户</span>
						</label>
					</div>
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod8"   name="mod8"  >
						  <span>MOD8往来单位</span>
						</label>
					</div>
                                       <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod9"   name="mod9"  >
						  <span>MOD9收/付款人</span>
						</label>
					</div>
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod10"   name="mod10"  >
						  <span>MOD10报销单</span>
						</label>
					</div> 
                                         <div class="input-field col s2" style="margin-top: 17px;width: 174px;" >
						<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="reminder"   name="reminder"  >
						  <span>MOD11授权</span>
						</label>
						<input
							 value="<?php echo date($DATE);?>"
							 id="end"
							 name="end"
							 type="text"
							 class="datepicker" style="    width: 85px;    margin-left: 27px;    margin-top: 0px;    height: 30px;"
							 maxlength="<?php strlen($PICK); ?>"
							 data-length="<?php strlen($PICK); ?>" required="required"/>
					</div>  
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod12"   name="mod12"  >
						  <span>MOD12贷款人总数</span>
						</label>
					</div>     
                                       <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="borrow"   name="borrow"  >
						  <span>MOD13贷/付</span>
						</label>
					</div>
                           <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="condition"   name="condition"  >
						  <span>MOD14查询</span>
						</label>
					</div>	
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod15"   name="mod15"  >
						  <span>MOD15文件管理器</span>
						</label>
					</div> 
                                        
                                         <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod16"   name="mod16"  >
						  <span>MOD16API</span>
						</label>
					</div>   
                                        </div>    
                                        <div class="input-field col s12" style="    height: 40px;    margin-top: -15px;">		
                                       
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod17"   name="mod17"  >
						  <span>MOD17我的工作</span>
						</label>
					</div> 
                                        	
                                          
                                       <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod18"   name="mod18"  >
						  <span>MOD18图表</span>
						</label>
					</div>
                                        
					<div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="noti"   name="noti"  >
						  <span>MOD19通知</span>
						</label>
					</div>	
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod20"   name="mod20"  >
						  <span>MOD20收支汇总/日</span>
						</label>
					</div>	 
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod21"   name="mod21"  >
						  <span>Mod21新费用</span>
						</label>
					</div>	     
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod25"   name="mod25"  >
						  <span>Mod22F</span>
						</label>
					</div>	   
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod26"   name="mod26"  >
						  <span>Mod23建档</span>
						</label>
					</div>	
                                        <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod27"   name="mod27"  >
						  <span>Mod24柜量统计</span>
						</label>
					</div>
                                            <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod28"   name="mod28"  >
						  <span>Mod25工资</span>
						</label>
					</div>
                                            <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod29"   name="mod29"  >
						  <span>Mod26</span>
						</label>
					</div>
                                            <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod22"   name="mod22"  >
						  <span>Modaa设置</span>
						</label>
					</div>	     
                                            
                                            <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod23"   name="mod23"  >
						  <span>Modab用户</span>
						</label>
					</div>	 
                                            
                                            <div class="input-field col s1" style="    margin: 0;" >
					<label class="pure-material-checkbox">
						  <input type="checkbox"  value="1"  id="mod24"   name="mod24"  >
						  <span>Modac修订</span>
						</label>
					</div>	 
                                       </div>    
                </div>
            </form>
        </div>
    <?php
}

$order = json_decode(file_get_contents('data/Documents.json'),true);

foreach ($order as $k){
	if( $k['controlerrevisiontime'] > 0 ){
		$financeclicktoapproval[$k['controlerrevision']]++;
	}
}

// DATA TABLE
if (!empty($data)) {
    // LOOP EACH ENTRY
    ?>
        <table class="striped responsive-table  tablesorter" id="tab-table">
            <thead>
                <tr>
					<th></th>
                    <th><?php echo $i18n['Name']; ?></th>
                    <th><?php echo $i18n['Password']; ?></th>
                    <th><?php echo $i18n['Role']; ?></th>
					<th style="width:40%;">Accounting</th>
					<th style="width:27%;">Accounting Readonly</th>
					<?php if( $currentuser->gm == 1 || $currentuser->controler == 1 ){  ?>
					<th>Permission<br>允许</th>
					<th>Reminder<br>提醒</th>
					<th style="" >File Manager</th>
					<th style="width:50px;display:none;">Modified</th>					
                    <th style="width:70px;" ><?php echo $i18n['Action']; ?></th>
					<?php } ?>
                </tr>
            </thead>
        <tbody>
   <?php 
     $total_receivable = $total_amount = $total_profit = 0;
     $countNo = 0;
        foreach ($data as $key => $values) {   
		     $toast = 'M.toast({html: "<span>' . $values['name'] . '</span>' .
                    '<a href=\"?delete_id=' . $values['id'] . '\" class=\"toast-action\">' .
                    $i18n['DELETE'] . '</a> &nbsp; &nbsp;"});';
					if( $currentuser->gm != 1 && $values['location'] != $currentuser->location ) { continue; } 	
	            ?>    
                <tr>
					<td style="padding-left:2px">
						<form action="verify.php" method="POST">
							 <input name="u" value="<?= $values['name'] ?>" type="hidden">
							 <input name="p" value="<?= $values['password']?>" type="hidden">
							 <button style="   border: none;    background: none;    cursor: pointer;" ><i class="material-icons right" style="color:#009e32;line-height:1.5;margin:0px;padding:0px;">lock_open</i></button>
						</form>
					</td>
                    <td style="padding-left:5px"><?= $values['name'] ?> </td>
                    <td style="padding-left:5px"><?= $values['password']?></td>
                    <td style="padding-left:5px"><?php if( $values['gm'] == 1 ){echo 'GM'; }elseif( $values['role'] == 'Operator' ){echo 'Finance';}elseif( $values['role'] == 'Finance' ){echo 'Controller';}else{ echo $values['role']; } 
					if($values['location'] != ''){ echo '<br/>'.$values['location']; }  ?></td>					
					<td style="padding-left:5px">
					<div class="boxaccount">
					<?php 
					$arrtabaccounts = array();
					foreach ($values['account'] as $r){ 
						foreach ($tabs as $r1){ 
							if($r1->id == $r){ 
								$arrtabaccounts[$r1->tabsg][] = $r1->name;
								//echo '<div>'.$r1->name.'</div>&bull; ';
							}  
						}
					} 
					foreach($arrtabaccounts as $tabname => $accounts){
						echo '<div><b style=" color: #fff; background-color: #1b278a; display: block;
						text-align: center;">'.$tabname.'</b>';
						echo '<ul>';
						foreach($accounts as $accountname){
							echo '<li>'.$accountname.'</li>';
						}
						echo '</ul>';
						echo '</div>';
					}
					//print_r($arrtabaccounts);
					?>
					</div>
					</td>
					<td style="padding-left:5px">
					<?php foreach ($values['accountreadonly'] as $r){ foreach ( $tabs as $r1 ){ if($r1->id == $r){ echo $r1->name.', '; }  }} ?>
					</td>
					<?php if( $currentuser->gm == 1 || $currentuser->controler == 1 ){  ?>				
					<td style="padding-left:5px">
						<div class="boxiccc">
						<?php 
                                                if( $values['total'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD1余额汇总</div><?php }
						if( $values['totalconsignee'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD2财务报表</div><?php } 
						if( $values['totalmonth'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD3账户收支/月</div><?php } 
                                                 if( $values['mod4'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD4过账余额汇总</div><?php }   
						if( $values['changedcurrency'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD5汇率</div><?php }               
                                                if( $values['mod6'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD6Consignee</div><?php }
                                                if( $values['mod7'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD7客户</div><?php }
                                                if( $values['mod8'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD8往来单位</div><?php }    
                                                if( $values['mod9'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD9收/付款人</div><?php }
                                                if( $values['mod10'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD10报销单</div><?php }
                                                if( $values['reminder'] > 0){ ?> 
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD11授权</div><?php }
                                                if( $values['mod12'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD12贷款人总数</div><?php } 
						if( $values['borrow'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD13贷/付</div><?php } 
						if( $values['condition'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                MOD14查询</div><?php }
                                                if( $values['mod15'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD15文件管理器</div><?php }  
                                                if( $values['mod16'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD16API</div><?php }  
                                                if( $values['mod17'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD17我的工作</div><?php }
                                               if( $values['mod18'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD18图表</div><?php }
                                               if( $values['mod19'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD19通知</div><?php }   
						if( $values['chart'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD18图表</div><?php }
						if( $values['noti'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								MOD19通知</div><?php }
                                                if( $values['mod20'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                Mod20收支汇总/日 </div><?php }
                                                 if( $values['mod21'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                Mod21新费用 </div><?php }
						if( $values['customer'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								Customer/客户付款</div><?php } 
                                               if( $values['mod25'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                                Mod22F</div><?php } 
                                               if( $values['mod26'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                                Mod23建档</div><?php }   
                                                if( $values['mod27'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                                Mod24柜量统计</div><?php }   
                                                if( $values['mod28'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                                Mod25工资</div><?php } 
                                                                if( $values['mod29'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                                Mod26公司资料资产登记</div><?php }                     
                                               if( $values['mod22'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                Modaa设置 </div><?php }  
                                                if( $values['mod23'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                Modab用户  </div><?php }
                                                if( $values['cherry'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								Modab01任意地址登录</div><?php }
						if( $values['daytoseedata'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								Modab02可看日记账天数 <?php echo $values['daytoseedata']; ?> 天</div><?php }
                                                if( $values['companyinfo'] == 1 ){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
								Modab03公司资料登记</div><?php } 
                                                if( $values['mod24'] > 0){ ?>
							<div class="idvchkcs">
								<img src="https://htlservice.net/images/greenchk_60.png"/>
                                                                Modac修订</div><?php }
                                               ?>
                                                    
                                                    
                                                    
                                                    
						</div>
					</td>
					<td style="padding-left:5px">
						<?php if( $values['reminder'] == 1 ){ echo 'yes<br>'.$values['end'].'<br>'.$values['locationreminder'];} ?>
					</td>
					<td style="padding-left:5px">
						<a style="display:none;" href="#" title="<?php echo date('Y.m.d', $values['id'] ); ?>" ><?= $values['createbyname'];?></a>
						<?php echo implode('<br>',$values['filelocation']); ?>
					</td>
					<td style="padding-left:5px;display:none;">
						<a href="#" title="<?php echo date('Y.m.d', $values['modifiedtime'] ); ?>" ><?= $values['modifiedname']?></a>
					</td>
                    <td style="padding-left:5px">
                        <a class="tooltipped" data-position="top" data-tooltip="<?= $i18n['Click alert link for delete!']?>" href="#" onclick='<?php echo $toast; ?>' >
                            <i class="red-text text-darken-4 small material-icons">delete_forever</i>
                        </a>
                        <a class="tooltipped" data-position="top" data-tooltip="<?= $i18n['EDIT'] ?>" href="editUser.php?id=<?= $values['id'] ?>">
                            <i class="grey-text small material-icons">mode_edit</i>
                        </a>
                    </td>
					<?php } ?>
                </tr>
            <?php 
        }
    ?>
        </tbody>
        </table>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
		
<style>
	.boxaccount{		
		min-width: 260px;
		display: block;
		position: relative;
	}
	.boxaccount > div{
		vertical-align: middle;
		display: inline-block;
		padding-top: 5px;
		padding-bottom: 5px;
		width: 25%;
		float: left;
	}	
	.boxaccount > div b{
    border-left: 1px solid #fff;
    border-right: 1px solid #fff;}
	.boxaccount > div:first-child b{border-left-width: 0px;}
	.boxaccount > div:last-child b{border-right-width: 0px;}
	.boxaccount > div ul{margin-top: 0px;}
	.boxaccount > div ul li{	
		padding-left: 10px;
		/*list-style-type: circle;
		list-style-position: inside;*/
	}
	.boxiccc{		
		width: 420px;
		display: block;
		position: relative;
	}
	.idvchkcs{
		vertical-align: middle;
		display: flex;
		justify-content: left;
		align-items: center;
		padding-top: 5px;
		padding-bottom: 5px;
		width: 210px;
		float: left;
	}
	.idvchkcs img{display: inline-block;margin-right: 10px;width: 30px;}
table.tablesorter thead tr th {
    background-color: #1b278a;
    color: #fff;
}
table thead tr th {
    position: sticky;
    z-index: 100;
    top: 0;
}
table.striped>tbody>tr:nth-child(odd) {
    background-color: rgba(226, 226, 226, 0.75);
}
</style>		
    <?php
}
// ENDIF no data

    
 // ECHO PROGRESS-BAR (only if there is no search performed) SEE tpl/css/progress.css
if (@$_GET['q'] == '') {
    echo '<div class="progress tooltipped" data-position="top"' .
    ' data-tooltip="' . $done . '/' . count((array)$data) . ' ' . $TYPE .
    '" title="' . $done . '/' . count((array)$data) . ' ' . $TYPE . '">' .
    '<div class="progress-bar green" data-width="' . ($done / count((array)$data) * 100) .
    '" style="width:' . ($done / count((array)$data) * 100) . '%"></div></div>';
}

// var_dump($sortdate); die;
// FOOTER
include 'tpl/footer.php';
?>
