<?php

Doo::loadModel('itematt');

class ItemFile {

    private $__itemfile;

    function __construct() {
	$this->__itemfile = new ItemAtt();
    }

    public function insertItemFileRecord($postArray) {
	$this->__itemfile->mpid = $postArray['mpid'];
	$this->__itemfile->ownerid = $postArray['ownerid'];
	$this->__itemfile->itemid = $postArray['itemid'];
	$this->__itemfile->filename = $postArray['filename'];
	$this->__itemfile->fileext = $postArray['fileext'];
	$this->__itemfile->filesize = $postArray['filesize'];
	$this->__itemfile->filepath = $postArray['filepath'];
	$this->__itemfile->categoryid = $postArray['categoryid'];
	if (isset($postArray['tips']))
	    $this->__itemfile->tips = $postArray['tips'];
	$this->__itemfile->intime = time();
	return $this->__itemfile->insert();
    }

    public function getItemFileList($tenderid) {
	return $tenderid ? $this->__itemfile->find(array('where' => 'mpid=?', 'desc' => 'intime', 'param' => array($tenderid), 'asArray' => TRUE)) : FALSE;
    }

    public function updateItemFields($id, $fname, $tips) {
	$this->__itemfile->filename = iconv('GBK', 'UTF-8', $fname);
	$this->__itemfile->tips = iconv('GBK', 'UTF-8', $tips);
	return $this->__itemfile->update(array('where' => 'iaid=?', 'param' => array($id)));
    }

}

?>