<?php
/**
 * Copy Right IJH.CC
 * Each engineer has a duty to keep the code elegant
 * $Id$
 */

if(!defined('__CORE_DIR')){
    exit("Access Denied");
}

class Mdl_Staff_Comment extends Mdl_Table
{   
  
    protected $_table = 'staff_comment';
    protected $_pk = 'comment_id';
    protected $_cols = 'comment_id,staff_id,uid,order_id,score,content,have_photo,reply,reply_ip,reply_time,closed,clientip,dateline';
    
    public function create($data)
    {   
        $data['clientip'] = $data['clientip'] ? $data['clientip'] : __IP;
        $data['dateline'] = $data['dateline'] ? $data['dateline'] : __TIME;
        return $this->db->insert($this->_table, $data, true);
    }

    public function detail_by_order($order_id)
    {
        if(!$order_id = (int)$order_id){
            return false;
        }
        $sql = "SELECT * FROM ".$this->table($this->_table)." WHERE order_id='{$order_id}' LIMIT 1";
        if($row = $this->db->GetRow($sql)){
            $row = $this->_format_row($row);
        }
        return $row;
    }

}