Skip to content

Commit

Permalink
inc.ClassDMS.php - Added a new method to retrieve the next memo numbe…
Browse files Browse the repository at this point in the history
…r given a user and fixed bug where the getDocumetnIDByNumber method wasn't updated for the new name in a mysql table column.

inc.ClassFolder.php - Updated methodology to generate memo numbers. A new indexNumber column was added to tblMemoNumbers to contain the numeric portion of the memo number. The maximum value in the indexNumber column is found and 1 is added to it to automatically generate the next memo number. However, if a docNumber is passed in the addDocument method, it will be used instead only if it does not already exist.

op.AddDocument.php - Added a check to get post data if set for the document number. If set, pass it to the addDocument method.

class.AddDocument.php - Add an input to display the next memo number and allow user to modify it before submitting memo.

class.Search.php - Removed status column.
  • Loading branch information
Rachael Sewell committed Apr 12, 2016
1 parent cdfd337 commit a58f482
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 12 deletions.
16 changes: 15 additions & 1 deletion SeedDMS_Core/Core/inc.ClassDMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function getDocument($id) { /* {{{ */
function getDocumentIDByNumber($number) { /* {{{ */
if(!$number) return false;

$queryStr = "SELECT `document` AS `myDoc` FROM `tblMemoNumbers` WHERE `number`='".$number."' UNION SELECT `document` AS `myDoc` FROM `tblSpecNumbers` WHERE `number`='".$number."'";
$queryStr = "SELECT `documentID` AS `myDoc` FROM `tblMemoNumbers` WHERE `number`='".$number."' UNION SELECT `documentID` AS `myDoc` FROM `tblSpecNumbers` WHERE `number`='".$number."'";
$resArr = $this->db->getResultArray($queryStr);

if (is_bool($resArr) && !$resArr)
Expand All @@ -548,6 +548,20 @@ function getDocumentsByUser($user) { /* {{{ */
return $user->getDocuments();
} /* }}} */

/**
* Gets the next memo number for a given user.
* The return value does not include the
* user login string.
*
* @param int $userID
* @return int number of next memo
*/
function getNextMemoNum($userID) {
$queryStr = "SELECT MAX(indexNumber) AS num FROM tblMemoNumbers WHERE userID=".$userID;
$resArr = $this->db->getResultArray($queryStr);
return $resArr[0]["num"] + 1;
}

/**
* Returns all documents locked by a given user
*
Expand Down
22 changes: 14 additions & 8 deletions SeedDMS_Core/Core/inc.ClassFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,22 +842,28 @@ function addDocument($name, $comment, $expires, $owner, $keywords, $categories,
}
$memoID = $db->getInsertID();
// Get count of memos by user to generate the next doc num
$resArr = $db->getResultArray("SELECT COUNT(*) AS num FROM tblMemoNumbers WHERE userID=".$owner->getID()." FOR UPDATE");
// Document indexes will start at 0
$docIndex = (integer)$resArr[0]["num"]-1;
$resArr = $db->getResultArray("SELECT MAX(indexNumber) AS num FROM tblMemoNumbers WHERE userID=".$owner->getID()." FOR UPDATE");
// Document indexes will start at 1
$docIndex = (integer)$resArr[0]["num"] + 1;
// Assemble the new document number in format: <user login>-<index>
$docNum = $owner->_login."-".$docIndex;
$queryStr = "UPDATE tblMemoNumbers SET number='".$docNum."' WHERE id=".$memoID;
$queryStr = "UPDATE tblMemoNumbers SET indexNumber='".$docIndex."', number='".$docNum."' WHERE id=".$memoID;
if (!$db->getResult($queryStr)) {
$db->rollbackTransaction();
return false;
}
} else {
// Allow adding previously created documents with existing numbers.
$queryStr = "INSERT INTO tblMemoNumbers (documentID, userID, number, parade) VALUES (".$document->getID().", ".$owner->getID().", ".$docNumber.", ".$paradeDoc.")";
if (!$db->getResult($queryStr)) {
$db->rollbackTransaction();
// Check for collisions with already existing numbers
$resArr = $db->getResultArray("SELECT COUNT(*) AS num FROM tblMemoNumbers WHERE number='" . $owner->_login. " . " . $docNumber . "' FOR UPDATE");
if((integer)$resArr[0]["num"] != 0) {
return false;
} else {
// Allow adding previously created documents with existing numbers.
$queryStr = "INSERT INTO tblMemoNumbers (documentID, userID, indexNumber, number, parade) VALUES (".$document->getID().", ".$owner->getID().", ".$docNumber.", \"" . $owner->_login . "-" . $docNumber. "\", ".$paradeDoc.")";
if (!$db->getResult($queryStr)) {
$db->rollbackTransaction();
return "2";
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions install/create_tables-innodb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ CREATE TABLE `tblMemoNumbers` (
`id` int(11) NOT NULL auto_increment,
`userID` int(11) NOT NULL default '0',
`documentID` int(11) NOT NULL default '0',
`indexNumber` int(11) NOT NULL default '0',
`number` varchar(150) default NULL,
`parade` smallint(1) default '1',
PRIMARY KEY (`id`),
Expand Down
1 change: 1 addition & 0 deletions languages/en_GB/lang.inc
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ URL: [url]',
'no_version_check' => 'Checking for a new version of SeedDMS has failed! This could be caused by allow_url_fopen being set to 0 in your php configuration.',
'no_version_modification' => 'No version modification',
'no_workflow_available' => 'No workflow available',
'number' => 'Number',
'objectcheck' => 'Folder/Document check',
'obsolete' => 'Obsolete',
'october' => 'October',
Expand Down
8 changes: 7 additions & 1 deletion op/op.AddDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
if($version_comment == "" && isset($_POST["use_comment"]))
$version_comment = $comment;

if(isset($_POST['setDocNumber'])) {
$setDocNumber = $_POST['setDocNumber'];
} else {
$setDocNumber = null;
}

$keywords = $_POST["keywords"];
$categories = isset($_POST["categories"]) ? $_POST["categories"] : null;
if(isset($_POST["attributes"]))
Expand Down Expand Up @@ -309,7 +315,7 @@
$cats, $userfiletmp, basename($userfilename),
$fileType, $userfiletype, $sequence,
$reviewers, $approvers, $reqversion,
$version_comment, $attributes, $attributes_version, $workflow);
$version_comment, $attributes, $attributes_version, $workflow, $setDocNumber);

if (is_bool($res) && !$res) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("error_occured"));
Expand Down
4 changes: 4 additions & 0 deletions styles/bootstrap/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ img.mimeicon {
margin-bottom: 10px;
}

.input-margin-correction {
margin-bottom: 0 !important;
}

.input-with-button {
width: 85%;
}
Expand Down
6 changes: 6 additions & 0 deletions views/bootstrap/class.AddDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ function(data) {
<?php $this->contentSubHeading(getMLText("document_infos")); ?>
</td>
</tr>
<tr>
<td><?php printMLText("number");?>:</td>
<td><?php echo $user->_login . "&nbsp;-&nbsp;" ?><input class='input-margin-correction' type='text' name='setDocNumber' value='<?php
echo $dms->getNextMemoNum($user->getID());
?>'></td>
</tr>
<tr>
<td><?php printMLText("name");?>:</td>
<td><input class='input-block-level' type="text" name="name"></td>
Expand Down
2 changes: 0 additions & 2 deletions views/bootstrap/class.Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ function show() { /* {{{ */
print "<th>".getMLText("doc_number")."</th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";

$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout);
Expand Down Expand Up @@ -499,7 +498,6 @@ function show() { /* {{{ */
print htmlspecialchars($owner->getFullName());
$display_status=$lc->getStatus();
print "</td>";
print "<td>".getOverallStatusText($display_status["status"]). "</td>";
print "</tr>\n";
}
} elseif(get_class($entry) == $dms->getClassname('folder')) {
Expand Down

0 comments on commit a58f482

Please sign in to comment.