diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php
index d766856a..9fcc03ba 100755
--- a/app/Controllers/Inwardgateregister.php
+++ b/app/Controllers/Inwardgateregister.php
@@ -988,8 +988,9 @@ function viewIGRDetails()
$notification = new Notification();
- $history_content = "
IGR History
";
- $history = $result_for_history['history'];
+ $history_content = "
IGR History
";
+ // $history = $result_for_history['history']; // old
+ $history = $this->inwardgateregister_model->ViewIGRHistory($IGRNo);
if(!empty($history)){
$field_labels = [
@@ -1025,22 +1026,57 @@ function viewIGRDetails()
];
// $history_content = "
The following values have been edited:"; //old Format
- for ($j = 0; $j < count($history); $j++) {
- $field_name = $history[$j]->field;
- $readable_field = isset($field_labels[$field_name]) ? $field_labels[$field_name] : $field_name;
- $history_content .= "- " .
- (($history[$j]->IGRItem_No)
- ? $history[$j]->MaterialName . " (" . $history[$j]->MaterialCode . ") - "
- : "") .
- $readable_field . " " . $history[$j]->old_data .
- " was updated into " . $history[$j]->new_data .
- " by " . $history[$j]->history_by .
- " on " . $history[$j]->indian_date .
- " at " . $history[$j]->indian_time .
- "
";
- // $history_content .= "
" . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` .";
- }
- $history_content .= "
";
+ for ($j = 0; $j < count($history); $j++) {
+ $field_name = $history[$j]->field;
+ $readable_field = isset($field_labels[$field_name]) ? $field_labels[$field_name] : $field_name;
+
+ if(intval($history[$j]->is_add) === 1) {
+ $history_content .= $history[$j]->IGR_No . " was Created by " . $history[$j]->FullName . " on " . $history[$j]->indian_date . " at " . $history[$j]->indian_time . " ";
+
+ if ($history[$j]->field === "IGRStatus") {
+ $str1 = $history[$j]->new_data;
+ $str2 = preg_replace('/\bIGR\b/i', '', $str1);
+ $str2 = trim($str2);
+ $str2 = ($str2 === "CREATED") ? "GENERATED" : $str2;
+
+ $history_content .= $history[$j]->IGR_No . " was ` " . $str2 . " ` by " . $history[$j]->FullName .
+ " on " . $history[$j]->indian_date . " at " . $history[$j]->indian_time;
+ } else {
+ $history_content .= $history[$j]->IGR_No . " was ` GENERATED ` by " . $history[$j]->FullName .
+ " on " . $history[$j]->indian_date . " at " . $history[$j]->indian_time;
+ }
+ } else if (intval($history[$j]->is_edit) === 1) {
+ $str = $history[$j]->field;
+
+ if (!in_array($str, ["UpdateBY", "MaterialRcvdDate", "DeliveryChellanDate"])) {
+ $fieldName = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str);
+ $displayOldData = (empty($history[$j]->old_data)) ? " " : $history[$j]->old_data;
+ $displayNewData = (empty($history[$j]->new_data)) ? " " : $history[$j]->new_data;
+
+ if ($history[$j]->field === "IGRStatus") {
+ $displayOldData = trim(preg_replace('/\bIGR\b/i', '', $displayOldData));
+ $displayOldData = ($displayOldData === "CREATED") ? "GENERATED" : $displayOldData;
+
+ $displayNewData = trim(preg_replace('/\bIGR\b/i', '', $displayNewData));
+ $displayNewData = ($displayNewData === "CREATED") ? "GENERATED" : $displayNewData;
+ }
+
+ if ($displayNewData || $displayOldData) {
+ $materialPart = (!empty($history[$j]->IGRItem_No)) ? $history[$j]->MaterialName . " ( " . $history[$j]->MaterialCode . " ) - " : "";
+ $history_content .= "- ".$materialPart . $readable_field . " ` " . $displayOldData . " ` was Updated into ` " . $displayNewData . " ` by " .
+ $history[$j]->FullName . " on " . $history[$j]->indian_date . " at " . $history[$j]->indian_time. "
";
+
+ }
+ }
+ } else if (intval($history[$j]->is_delete) === 1) {
+ $str = $history[$j]->field;
+ $fieldName = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str);
+ $history_content .= "- ".$readable_field . " " . $history[$j]->new_data . " was deleted by " . $history[$j]->FullName .
+ " on " . $history[$j]->indian_date . " at " . $history[$j]->indian_time. "
";
+ }
+ // $history_content .= "
" . $readable_field . ": `" . $history[$j]->old_data . "` was updated to `" . $history[$j]->new_data . "` .";
+ }
+ $history_content .= "
";
$to_email_addr = "";
for ($i = 0; $i < count($result_for_email['to_mails']); $i++) {
@@ -1097,6 +1133,14 @@ function viewIGRDetails()
echo $finalstatement;
}
+ function generateSentence($record) {
+ $sentence = "";
+
+
+ return $sentence;
+}
+
+
function CancelIGR(){
# Step 1 : Gethering Data..