1<?php 2/* Definition of the PurchOrder class to hold all the information for a purchase order and delivery 3*/ 4 5 6Class PurchOrder { 7 8 var $LineItems; /*array of objects of class LineDetails using the product id as the pointer */ 9 var $CurrCode; 10 var $CurrDecimalPlaces; 11 var $ExRate; 12 var $Initiator; 13 var $DeliveryDate; 14 var $RequisitionNo; 15 var $DelAdd1; 16 var $DelAdd2; 17 var $DelAdd3; 18 var $DelAdd4; 19 var $DelAdd5; 20 var $DelAdd6; 21 var $Tel; 22 var $SuppDelAdd1; 23 var $SuppDelAdd2; 24 var $SuppDelAdd3; 25 var $SuppDelAdd4; 26 var $SuppDelAdd5; 27 var $SuppDelAdd6; 28 var $SupplierContact; 29 var $SuppTel; 30 var $Comments; 31 var $Location; 32 var $Managed; 33 var $SupplierID; 34 var $SupplierName; 35 var $Orig_OrderDate; 36 var $OrderNo; /*Only used for modification of existing orders otherwise only established when order committed */ 37 var $LinesOnOrder; 38 var $PrintedPurchaseOrder; 39 var $DatePurchaseOrderPrinted; 40 var $Total; 41 var $GLLink; /*Is the GL link to stock activated only checked when order initiated or reading in for modification */ 42 var $Version; 43 var $Status; 44 var $StatusComments; 45 var $AllowPrintPO; 46 var $Revised; 47 var $DeliveryBy; 48 var $PaymentTerms; 49 var $Contact; 50 var $Port; 51 52 function __construct(){ 53 /*Constructor function initialises a new purchase order object */ 54 $this->LineItems = array(); 55 $this->total=0; 56 $this->LinesOnOrder=0; 57 } 58 59 function PurchOrder() { 60 self::__construct(); 61 } 62 63 function add_to_order($LineNo, 64 $StockID, 65 $Serialised, 66 $Controlled, 67 $Qty, 68 $ItemDescr, 69 $Price, 70 $UOM, 71 $GLCode, 72 $ReqDelDate, 73 $ShiptRef, 74 $Completed, 75 $JobRef, 76 $QtyInv=0, 77 $QtyRecd=0, 78 $GLActName='', 79 $DecimalPlaces=2, 80 $SuppliersUnit, 81 $ConversionFactor=1, 82 $LeadTime=1, 83 $Suppliers_PartNo='', 84 $AssetID=0){ 85 86 if ($Qty!=0 && isset($Qty)){ 87 88 $this->LineItems[$LineNo] = new LineDetails($LineNo, 89 $StockID, 90 $Serialised, 91 $Controlled, 92 $Qty, 93 $ItemDescr, 94 $Price, 95 $UOM, 96 $GLCode, 97 $ReqDelDate, 98 $ShiptRef, 99 $Completed, 100 $JobRef, 101 $QtyInv, 102 $QtyRecd, 103 $GLActName, 104 $DecimalPlaces, 105 $SuppliersUnit, 106 $ConversionFactor, 107 $LeadTime, 108 $Suppliers_PartNo, 109 $AssetID); 110 $this->LinesOnOrder++; 111 Return 1; 112 } 113 Return 0; 114 } 115 116 function update_order_item($LineNo, 117 $Qty, 118 $Price, 119 $ItemDescription, 120 $GLCode, 121 $GLAccountName, 122 $ReqDelDate, 123 $ShiptRef, 124 $JobRef , 125 $SuppliersUnit, 126 $ConversionFactor, 127 $Suppliers_PartNo){ 128 129 $this->LineItems[$LineNo]->ItemDescription = $ItemDescription; 130 $this->LineItems[$LineNo]->Quantity = $Qty; 131 $this->LineItems[$LineNo]->Price = $Price; 132 $this->LineItems[$LineNo]->GLCode = $GLCode; 133 $this->LineItems[$LineNo]->GLAccountName = $GLAccountName; 134 $this->LineItems[$LineNo]->ReqDelDate = $ReqDelDate; 135 $this->LineItems[$LineNo]->ShiptRef = $ShiptRef; 136 $this->LineItems[$LineNo]->JobRef = $JobRef; 137 $this->LineItems[$LineNo]->SuppliersUnit = $SuppliersUnit; 138 $this->LineItems[$LineNo]->ConversionFactor = $ConversionFactor; 139 $this->LineItems[$LineNo]->Suppliers_PartNo = $Suppliers_PartNo; 140 } 141 142 function remove_from_order(&$LineNo){ 143 $this->LineItems[$LineNo]->Deleted = True; 144 } 145 146 147 function Any_Already_Received(){ 148 /* Checks if there have been deliveries or invoiced entered against any of the line items */ 149 if (count($this->LineItems)>0){ 150 foreach ($this->LineItems as $OrderedItems) { 151 if ($OrderedItems->QtyReceived !=0 OR $OrderedItems->QtyInv !=0){ 152 return 1; 153 } 154 } 155 } 156 return 0; 157 } 158 159 function Any_Lines_On_A_Shipment(){ 160 /* Checks if any of the line items are on a shipment */ 161 if (count($this->LineItems)>0){ 162 foreach ($this->LineItems as $OrderedItems) { 163 if ($OrderedItems->ShiptRef !=''){ 164 return $OrderedItems->ShiptRef; 165 } 166 } 167 } 168 return 0; 169 } 170 function Some_Already_Received($LineNo){ 171 /* Checks if there have been deliveries or amounts invoiced against a specific line item */ 172 if (count($this->LineItems)>0 and isset($this->LineItems[$LineNo])){ 173 if ($this->LineItems[$LineNo]->QtyReceived !=0 or $this->LineItems[$LineNo]->QtyInv !=0){ 174 return 1; 175 } 176 } 177 return 0; 178 } 179 180 function Order_Value() { 181 $TotalValue=0; 182 foreach ($this->LineItems as $OrderedItems) { 183 if ($OrderedItems->Deleted == False){ 184 $TotalValue += ($OrderedItems->Price)*($OrderedItems->Quantity); 185 } 186 } 187 return $TotalValue; 188 } 189 190 function AllLinesReceived(){ 191 foreach ($this->LineItems as $OrderedItems) { 192 if (($OrderedItems->QtyReceived + $OrderedItems->ReceiveQty) < $OrderedItems->Quantity){ 193 return 0; 194 } 195 } 196 return 1; //all lines must be fully received 197 } 198 199 function SomethingReceived(){ 200 foreach ($this->LineItems as $OrderedItems) { 201 if ($OrderedItems->ReceiveQty !=0){ 202 return 1; 203 } 204 } 205 return 0; //nowt received 206 } 207 208} /* end of class defintion */ 209 210Class LineDetails { 211/* PurchOrderDetails */ 212 Var $LineNo; 213 Var $PODetailRec; 214 Var $StockID; 215 Var $ItemDescription; 216 Var $DecimalPlaces; 217 Var $GLCode; 218 Var $GLActName; 219 Var $Quantity; 220 Var $Price; 221 Var $Units; 222 Var $ReqDelDate; 223 Var $QtyInv; 224 Var $QtyReceived; 225 Var $StandardCost; 226 var $ShiptRef; 227 var $Completed; 228 Var $JobRef; 229 var $ConversionFactor; 230 var $SuppliersUnit; 231 Var $Suppliers_PartNo; 232 Var $LeadTime; 233 Var $ReceiveQty; //this receipt of stock 234 Var $Deleted; 235 Var $Controlled; 236 Var $Serialised; 237 Var $SerialItems; /*An array holding the batch/serial numbers and quantities in each batch*/ 238 Var $AssetID; 239 240 function __construct ( $LineNo, 241 $StockItem, 242 $Serialised, 243 $Controlled, 244 $Qty, 245 $ItemDescr, 246 $Price, 247 $UOM, 248 $GLCode, 249 $ReqDelDate, 250 $ShiptRef =0, 251 $Completed, 252 $JobRef, 253 $QtyInv, 254 $QtyRecd, 255 $GLActName, 256 $DecimalPlaces, 257 $SuppliersUnit, 258 $ConversionFactor, 259 $LeadTime, 260 $Suppliers_PartNo, 261 $AssetID) { 262 263 /* Constructor function to add a new LineDetail object with passed params */ 264 $this->LineNo = $LineNo; 265 $this->StockID =$StockItem; 266 $this->Controlled = $Controlled; 267 $this->Serialised = $Serialised; 268 $this->DecimalPlaces=$DecimalPlaces; 269 $this->ItemDescription = $ItemDescr; 270 $this->Quantity = $Qty; 271 $this->ReqDelDate = $ReqDelDate; 272 $this->Price = $Price; 273 $this->Units = $UOM; 274 $this->QtyReceived = $QtyRecd; 275 $this->QtyInv = $QtyInv; 276 $this->GLCode = $GLCode; 277 $this->JobRef = $JobRef; 278 $this->SuppliersUnit = $SuppliersUnit; 279 $this->ConversionFactor = $ConversionFactor; 280 $this->Suppliers_PartNo = $Suppliers_PartNo; 281 $this->LeadTime = $LeadTime; 282 if (is_numeric($ShiptRef)){ 283 $this->ShiptRef = $ShiptRef; 284 } else { 285 $this->ShiptRef = 0; 286 } 287 $this->Completed = $Completed; 288 $this->GLActName = $GLActName; 289 $this->ReceiveQty = 0; /*initialise these last two only */ 290 $this->StandardCost = 0; 291 $this->Deleted = false; 292 $this->SerialItems = array(); /*if Controlled then need to populate this later */ 293 $this->SerialItemsValid=false; 294 $this->AssetID = $AssetID; 295 296 } 297 function LineDetails($LineNo, 298 $StockItem, 299 $Serialised, 300 $Controlled, 301 $Qty, 302 $ItemDescr, 303 $Price, 304 $UOM, 305 $GLCode, 306 $ReqDelDate, 307 $ShiptRef =0, 308 $Completed, 309 $JobRef, 310 $QtyInv, 311 $QtyRecd, 312 $GLActName, 313 $DecimalPlaces, 314 $SuppliersUnit, 315 $ConversionFactor, 316 $LeadTime, 317 $Suppliers_PartNo, 318 $AssetID) { 319 self::__construct($LineNo, 320 $StockItem, 321 $Serialised, 322 $Controlled, 323 $Qty, 324 $ItemDescr, 325 $Price, 326 $UOM, 327 $GLCode, 328 $ReqDelDate, 329 $ShiptRef =0, 330 $Completed, 331 $JobRef, 332 $QtyInv, 333 $QtyRecd, 334 $GLActName, 335 $DecimalPlaces, 336 $SuppliersUnit, 337 $ConversionFactor, 338 $LeadTime, 339 $Suppliers_PartNo, 340 $AssetID); 341 } 342} 343?> 344