<?php

/*
 * lib_manage相关函数库
 * 
============================================================================
 * 版权所有 2012-2020 深圳朝九科技有限公司，并保留所有权利。
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: Yukey  QQ:2787720874
*/

if (!defined('YUKEY'))
{
    die('Hacking attempt');
}

/**
 * 获得projects下的项目列表
 *
*/
function manage_count($table,$k,$v,$sql='')
{
	($k !='' && $v !='') ? $condition = " WHERE $k='$v' " : $condition ='';
	if($_SESSION['tbRank']>='70'){
       $sql = "SELECT COUNT(*) FROM " . $GLOBALS['si']->table($table);
    }else{
	   $sql = "SELECT COUNT(*) FROM " . $GLOBALS['si']->table($table). $condition;
	}
	
     if ($sql!=''){
     	return $GLOBALS['db']->getOne($sql);
     }else {
     	return false;
	 }
}


function manage_list($table,$start,$num,$order,$k,$v,$sql='')
{
	($k !='' && $v !='') ? $condition = " WHERE $k='$v' " : $condition ='';
	if($_SESSION['tbRank']>='70'){
	   $sql = "SELECT * FROM " . $GLOBALS['si']->table($table) . $condition . " ORDER BY $order ASC LIMIT $start,$num";
	}else{
	   $sql = "SELECT * FROM " . $GLOBALS['si']->table($table) . $condition;
	}
	 
	 if ($sql!=''){
     	return $GLOBALS['db']->getAll($sql);
     }else {
     	return false;
     }
}

function del_defect($id)
{
	if($_SESSION['tbRank'])
	{
	     $sql = "DELETE FROM " . $GLOBALS['si']->table('defects') . " WHERE tbSN='".$id."'";	 
		 if ($sql!=''){
		 return $GLOBALS['db']->query($sql);
		 }else{
		 return false;
		 }
	} else{
	return false;
	}
} 


?>