mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 09:35:00 +00:00
add class for handling transmittals
This commit is contained in:
parent
7338ddaadd
commit
01b55843d2
|
@ -293,6 +293,8 @@ class SeedDMS_Core_DMS {
|
|||
$this->classnames['documentcontent'] = 'SeedDMS_Core_DocumentContent';
|
||||
$this->classnames['user'] = 'SeedDMS_Core_User';
|
||||
$this->classnames['group'] = 'SeedDMS_Core_Group';
|
||||
$this->classnames['transmittal'] = 'SeedDMS_Core_Transmittal';
|
||||
$this->classnames['transmittalitem'] = 'SeedDMS_Core_TransmittalItem';
|
||||
$this->version = '@package_version@';
|
||||
if($this->version[0] == '@')
|
||||
$this->version = '4.3.17';
|
||||
|
@ -1482,6 +1484,60 @@ class SeedDMS_Core_DMS {
|
|||
return $this->getGroup($this->db->getInsertID());
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get a transmittal by its id
|
||||
*
|
||||
* @param integer $id id of transmittal
|
||||
* @return object/boolean transmittal or false if no group was found
|
||||
*/
|
||||
function getTransmittal($id) { /* {{{ */
|
||||
$classname = $this->classnames['transmittal'];
|
||||
return $classname::getInstance($id, $this, '');
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get a transmittal by its name
|
||||
*
|
||||
* @param string $name name of transmittal
|
||||
* @return object/boolean transmittal or false if no group was found
|
||||
*/
|
||||
function getTransmittalByName($name) { /* {{{ */
|
||||
$classname = $this->classnames['transmittal'];
|
||||
return $classname::getInstance($name, $this, 'name');
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Return list of all transmittals
|
||||
*
|
||||
* @return array of instances of {@link SeedDMS_Core_Transmittal} or false
|
||||
*/
|
||||
function getAllTransmittals($user=null, $orderby = '') { /* {{{ */
|
||||
$classname = $this->classnames['transmittal'];
|
||||
return $classname::getAllInstances($user, $orderby, $this);
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Create a new transmittal
|
||||
*
|
||||
* @param string $name name of group
|
||||
* @param string $comment comment of group
|
||||
* @param object $user user this transmittal belongs to
|
||||
* @return object/boolean instance of {@link SeedDMS_Core_Transmittal} or
|
||||
* false in case of an error.
|
||||
*/
|
||||
function addTransmittal($name, $comment, $user) { /* {{{ */
|
||||
if (is_object($this->getTransmittalByName($name))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$queryStr = "INSERT INTO tblTransmittals (name, comment, userID) VALUES (".$this->db->qstr($name).", ".$this->db->qstr($comment).", ".$user->getID().")";
|
||||
echo $queryStr;
|
||||
if (!$this->db->getResult($queryStr))
|
||||
return false;
|
||||
|
||||
return $this->getTransmittal($this->db->getInsertID());
|
||||
} /* }}} */
|
||||
|
||||
function getKeywordCategory($id) { /* {{{ */
|
||||
if (!is_numeric($id))
|
||||
return false;
|
||||
|
|
333
SeedDMS_Core/Core/inc.ClassTransmittal.php
Normal file
333
SeedDMS_Core/Core/inc.ClassTransmittal.php
Normal file
|
@ -0,0 +1,333 @@
|
|||
<?php
|
||||
/**
|
||||
* Implementation of the transmittal object in the document management system
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS_Core
|
||||
* @license GPL 2
|
||||
* @version @version@
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal, 2006-2008 Malcolm Cowe,
|
||||
* 2010 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class to represent a transmittal in the document management system
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS_Core
|
||||
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal, 2006-2008 Malcolm Cowe,
|
||||
* 2010 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Core_Transmittal {
|
||||
/**
|
||||
* @var integer id of transmittal
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_id;
|
||||
|
||||
/**
|
||||
* @var string name of transmittal
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_name;
|
||||
|
||||
/**
|
||||
* @var string comment of transmittal
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_comment;
|
||||
|
||||
/**
|
||||
* @var boolean true if transmittal is public
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_isPublic;
|
||||
|
||||
/**
|
||||
* @var object user this transmittal belongs to
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_user;
|
||||
|
||||
/**
|
||||
* @var object date of creation
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_date;
|
||||
|
||||
/**
|
||||
* @var object items
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_items;
|
||||
|
||||
/**
|
||||
* @var object reference to the dms instance this user belongs to
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_dms;
|
||||
|
||||
function SeedDMS_Core_Transmittal($id, $user, $name, $comment, $isPublic=0, $date='0000-00-00 00:00:00') {
|
||||
$this->_id = $id;
|
||||
$this->_name = $name;
|
||||
$this->_comment = $comment;
|
||||
$this->_user = $user;
|
||||
$this->_isPublic = $isPublic;
|
||||
$this->_date = $date;
|
||||
$this->_items = array();
|
||||
$this->_dms = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of a transmittal object
|
||||
*
|
||||
* @param string|integer $id id or name of transmittal, depending
|
||||
* on the 3rd parameter.
|
||||
* @param object $dms instance of dms
|
||||
* @param string $by search by [id|name]. If this
|
||||
* parameter is left empty, the user will be search by its Id.
|
||||
* @return object instance of class SeedDMS_Core_Transmittal
|
||||
*/
|
||||
public static function getInstance($id, $dms, $by='') { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
||||
switch($by) {
|
||||
case 'name':
|
||||
$queryStr = "SELECT * FROM `tblTransmittals` WHERE `name` = ".$db->qstr($id);
|
||||
break;
|
||||
default:
|
||||
$queryStr = "SELECT * FROM `tblTransmittals` WHERE id = " . (int) $id;
|
||||
}
|
||||
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
|
||||
if (is_bool($resArr) && $resArr == false) return false;
|
||||
if (count($resArr) != 1) return false;
|
||||
|
||||
$resArr = $resArr[0];
|
||||
|
||||
$uclassname = $dms->getClassname('user');
|
||||
$user = $uclassname::getInstance($resArr['userID'], $dms);
|
||||
$transmittal = new self($resArr["id"], $user, $resArr["name"], $resArr["comment"], $resArr["public"], $resArr["date"]);
|
||||
$transmittal->setDMS($dms);
|
||||
return $transmittal;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get all instances of a transmittal object
|
||||
*
|
||||
* @param string|integer $id id or name of transmittal, depending
|
||||
* on the 3rd parameter.
|
||||
* @param object $dms instance of dms
|
||||
* @param string $by search by [id|name]. If this
|
||||
* parameter is left empty, the user will be search by its Id.
|
||||
* @return object instance of class SeedDMS_Core_Transmittal
|
||||
*/
|
||||
public static function getAllInstances($user, $orderby, $dms) { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
||||
$queryStr = "SELECT * FROM `tblTransmittals`";
|
||||
if($user)
|
||||
$queryStr .= " WHERE userID = " . $user->getID();
|
||||
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
|
||||
if (is_bool($resArr) && $resArr == false) return false;
|
||||
|
||||
$uclassname = $dms->getClassname('user');
|
||||
$transmittals = array();
|
||||
foreach ($resArr as $res) {
|
||||
$user = $uclassname::getInstance($res['userID'], $dms);
|
||||
$transmittal = new self($res["id"], $user, $res["name"], $res["comment"], $res["public"], $res["date"]);
|
||||
$transmittal->setDMS($dms);
|
||||
$transmittals[] = $transmittal;
|
||||
}
|
||||
return $transmittals;
|
||||
} /* }}} */
|
||||
|
||||
function setDMS($dms) {
|
||||
$this->_dms = $dms;
|
||||
}
|
||||
|
||||
function getID() { return $this->_id; }
|
||||
|
||||
function getName() { return $this->_name; }
|
||||
|
||||
function setName($newName) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$queryStr = "UPDATE tblTransmittals SET name =".$db->qstr($newName)." WHERE id = " . $this->_id;
|
||||
$res = $db->getResult($queryStr);
|
||||
if (!$res)
|
||||
return false;
|
||||
|
||||
$this->_name = $newName;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
function getComment() { return $this->_comment; }
|
||||
|
||||
function setComment($newComment) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$queryStr = "UPDATE tblTransmittals SET comment =".$db->qstr($newComment)." WHERE id = " . $this->_id;
|
||||
$res = $db->getResult($queryStr);
|
||||
if (!$res)
|
||||
return false;
|
||||
|
||||
$this->_comment = $newComment;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
function getItems() { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if (!$this->_items) {
|
||||
$queryStr = "SELECT `tblTransmittalItems`.* FROM `tblTransmittalItems` ".
|
||||
"LEFT JOIN `tblDocuments` ON `tblTransmittalItems`.`document`=`tblDocuments`.`id` ".
|
||||
"WHERE `tblTransmittalItems`.`transmittal` = '". $this->_id ."'";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$this->_users = array();
|
||||
|
||||
$classname = $this->_dms->getClassname('transmittalitem');
|
||||
foreach ($resArr as $row) {
|
||||
$document = $this->_dms->getDocument($row['document']);
|
||||
$content = $document->getContentByVersion($row['version']);
|
||||
$item = new $classname($row["id"], $this, $content, $row["date"]);
|
||||
array_push($this->_items, $item);
|
||||
}
|
||||
}
|
||||
return $this->_items;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add an item to the transmittal
|
||||
*
|
||||
* @param object $item instance of SeedDMS_Core_DocumentContent
|
||||
* @return boolean true if item could be added, otherwise false
|
||||
*/
|
||||
function addContent($item) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if(get_class($item) != $this->_dms->getClassname('documentcontent'))
|
||||
return false;
|
||||
|
||||
$document = $item->getDocument();
|
||||
$queryStr = "INSERT INTO `tblTransmittalItems` (`transmittal`, `document`, `version`, `date`) ".
|
||||
"VALUES ('". $this->_id ."', $document->getID(), $item->getVersion(), CURRENT_TIMESTAMP)";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
return false;
|
||||
}
|
||||
$itemID = $db->getInsertID();
|
||||
|
||||
return SeedDMS_Core_TransmittalItem::getInstance($itemID);
|
||||
} /* }}} */
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to represent a transmittal in the document management system
|
||||
*
|
||||
* @category DMS
|
||||
* @package SeedDMS_Core
|
||||
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @copyright Copyright (C) 2002-2005 Markus Westphal, 2006-2008 Malcolm Cowe,
|
||||
* 2010 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Core_TransmittalItem {
|
||||
/**
|
||||
* @var integer id of transmittal item
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_id;
|
||||
|
||||
/**
|
||||
* @var object document content
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_content;
|
||||
|
||||
/**
|
||||
* @var object transmittal
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_transmittal;
|
||||
|
||||
/**
|
||||
* @var object date of creation
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
var $_date;
|
||||
|
||||
function SeedDMS_Core_TransmittalItem($id, $transmittal, $content, $date='0000-00-00 00:00:00') {
|
||||
$this->_id = $id;
|
||||
$this->_transmittal = $transmittal;
|
||||
$this->_content = $content;
|
||||
$this->_date = $date;
|
||||
$this->_dms = null;
|
||||
}
|
||||
|
||||
public static function getInstance($id, $dms) { /* {{{ */
|
||||
$db = $dms->getDB();
|
||||
|
||||
$queryStr = "SELECT * FROM tblTransmittalItems WHERE id = " . (int) $id;
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
if (count($resArr) != 1)
|
||||
return false;
|
||||
$resArr = $resArr[0];
|
||||
|
||||
$transmittal = SeedDMS_Core_Transmittal::getInstance($resArr['transmittal'], $dms);
|
||||
$dclassname = $dms->getClassname('document');
|
||||
$document = $dclassname::getInstance($resArr['document'], $dms);
|
||||
$content = $document->getVersion($resArr['version']);
|
||||
|
||||
$item = new self($resArr["id"], $transmittal, $content, $resArr["date"]);
|
||||
$item->setDMS($dms);
|
||||
return $item;
|
||||
} /* }}} */
|
||||
|
||||
function setDMS($dms) {
|
||||
$this->_dms = $dms;
|
||||
}
|
||||
|
||||
function getID() { return $this->_id; }
|
||||
|
||||
function getContent() { return $this->_content; }
|
||||
|
||||
function getDate() { return $this->_date; }
|
||||
|
||||
function remove() { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
$transmittal = $this->_transmittal;
|
||||
|
||||
$queryStr = "DELETE FROM tblTransmittalItems WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} /* }}} */
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user