forked from timschofield/webERP-Medical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContractOtherReqts.php
149 lines (120 loc) · 6.99 KB
/
ContractOtherReqts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/* $Id: $ */
include('includes/DefineContractClass.php');
include('includes/session.inc');
$title = _('Contract Other Requirements');
$identifier=$_GET['identifier'];
/* If a contract header does not exist, then go to
* Contracts.php to create one
*/
if (!isset($_SESSION['Contract'.$identifier])){
header('Location:' . $rootpath . '/Contracts.php');
exit;
}
include('includes/header.inc');
if (isset($_POST['UpdateLines']) OR isset($_POST['BackToHeader'])) {
if($_SESSION['Contract'.$identifier]->Status!=2){ //dont do anything if the customer has committed to the contract
foreach ($_SESSION['Contract'.$identifier]->ContractReqts as $ContractComponentID => $ContractRequirementItem) {
if ($_POST['Qty'.$ContractComponentID]==0){
//this is the same as deleting the line - so delete it
$_SESSION['Contract'.$identifier]->Remove_ContractRequirement($ContractComponentID);
} else {
$_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Quantity=filter_number_input($_POST['Qty'.$ContractComponentID]);
$_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->CostPerUnit=filter_currency_input($_POST['CostPerUnit'.$ContractComponentID]);
$_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Requirement=$_POST['Requirement'.$ContractComponentID];
}
} // end loop around the items on the contract requirements array
} // end if the contract is not currently committed to by the customer
}// end if the user has hit the update lines or back to header buttons
if (isset($_POST['BackToHeader'])){
echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/Contracts.php?identifier='.$identifier. '" />';
echo '<br />';
prnMsg(_('You should automatically be forwarded to the Contract page. If this does not happen perhaps the browser does not support META Refresh') . '<a href="' . $rootpath . '/Contracts.php?identifier='.$identifier . '">' . _('click here') . '</a> ' . _('to continue'),'info');
include('includes/footer.inc');
exit;
}
if(isset($_GET['Delete'])){
if($_SESSION['Contract'.$identifier]->Status!=2){
$_SESSION['Contract'.$identifier]->Remove_ContractRequirement($_GET['Delete']);
} else {
prnMsg( _('The other contract requirements cannot be altered because the customer has already placed the order'),'warn');
}
}
if (isset($_POST['EnterNewRequirement'])){
$InputError = false;
if (!is_numeric(filter_number_input($_POST['Quantity']))){
prnMsg(_('The quantity of the new requirement is expected to be numeric'),'error');
$InputError = true;
}
if (!is_numeric(filter_currency_input($_POST['CostPerUnit']))){
prnMsg(_('The cost per unit of the new requirement is expected to be numeric'),'error');
$InputError = true;
}
if (!$InputError){
$_SESSION['Contract'.$identifier]->Add_To_ContractRequirements ($_POST['RequirementDescription'],
filter_number_input($_POST['Quantity']),
filter_currency_input($_POST['CostPerUnit']));
unset($_POST['RequirementDescription']);
unset($_POST['Quantity']);
unset($_POST['CostPerUnit']);
}
}
/* This is where the other requirement as entered/modified should be displayed reflecting any deletions or insertions*/
echo '<form name="ContractReqtsForm" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?identifier='.$identifier. '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/contract.png" title="' ._('Contract Other Requirements') . '" alt="" /> ' .
_('Contract Other Requirements') . ' - ' . $_SESSION['Contract'.$identifier]->CustomerName.'</p>';
if (count($_SESSION['Contract'.$identifier]->ContractReqts)>0){
echo '<table cellpadding="2" class="selection">';
if (isset($_SESSION['Contract'.$identifier]->ContractRef)) {
echo '<tr><th colspan="5">' . _('Contract Reference:') .' '. $_SESSION['Contract'.$identifier]->ContractRef.'</th></tr>';
}
echo '<tr>
<th>' . _('Description') . '</th>
<th>' . _('Quantity') . '</th>
<th>' . _('Unit Cost') . '</th>
<th>' . _('Sub-total') . '</th>
</tr>';
$_SESSION['Contract'.$identifier]->total = 0;
$k = 0; //row colour counter
$TotalCost =0;
foreach ($_SESSION['Contract'.$identifier]->ContractReqts as $ContractReqtID => $ContractComponent) {
$LineTotal = $ContractComponent->Quantity * $ContractComponent->CostPerUnit;
$DisplayLineTotal = locale_money_format($LineTotal,$_SESSION['Contract'.$identifier]->CurrCode);
if ($k==1){
echo '<tr class="EvenTableRows">';
$k=0;
} else {
echo '<tr class="OddTableRows">';
$k=1;
}
echo '<td><textarea name="Requirement' . $ContractReqtID . '" cols="30" rows="3">' . $ContractComponent->Requirement . '</textarea></td>
<td><input type="text" class="number" name="Qty' . $ContractReqtID . '" size="11" value="' . locale_number_format($ContractComponent->Quantity,2) . '" /></td>
<td><input type="text" class="number" name="CostPerUnit' . $ContractReqtID . '" size="11" value="' . locale_money_format($ContractComponent->CostPerUnit,$_SESSION['Contract'.$identifier]->CurrCode) . '" /></td>
<td class="number">' . $DisplayLineTotal . '</td>
<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?identifier='.$identifier. '&Delete=' . $ContractReqtID . '">' . _('Delete') . '</a></td></tr>';
$TotalCost += $LineTotal;
}
$DisplayTotal = locale_money_format($TotalCost,$_SESSION['Contract'.$identifier]->CurrCode);
echo '<tr><td colspan="4" class="number">' . _('Total Other Requirements Cost') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>';
echo '<br /><div class="centre"><button type="submit" name="UpdateLines">' . _('Update Other Requirements Lines') . '</button>';
echo '<button type="submit" name="BackToHeader">' . _('Back To Contract Header') . '</button></div>';
} /*Only display the contract other requirements lines if there are any !! */
echo '<br />';
/*Now show form to add new requirements to the contract */
if (!isset($_POST['RequirementDescription'])) {
$_POST['RequirementDescription']='';
$_POST['Quantity']=0;
$_POST['CostPerUnit']=0;
}
echo '<table class="selection">
<tr><th colspan="2" class="header">' . _('Enter New Requirements') . '</th></tr>
<tr><td>' . _('Requirement Description') . '</td>
<td><textarea name="RequirementDescription" cols="30" rows="3">' . $_POST['RequirementDescription'] . '</textarea></td></tr>';
echo '<tr><td>' . _('Quantity Required') . ':</td><td><input type="text" class="number" name="Quantity" size="10" maxlength="10" value="' . $_POST['Quantity'] . '" /></td></tr>';
echo '<tr><td>' . _('Cost Per Unit') . ':</td><td><input type="text" class="number" name="CostPerUnit" size="10" maxlength="10" value="' . $_POST['CostPerUnit'] . '" /></td></tr>';
echo '</table>';
echo '<br /><div class="centre"><button type="submit" name="EnterNewRequirement">' . _('Enter New Contract Requirement') . '</button></div><br />';
echo '</form>';
include('includes/footer.inc');
?>