Pxx$orderid Suppliers Purchase Orders"; ?>
fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $contactid=$row['contact_id']; $cid=$row['company_id']; $hostcompany=$row['hostcompanyid']; if ($hostcompany==4) { $narrowpor='SR'.(isset($global_company_prefix[$hostcompany]) ? $global_company_prefix[$hostcompany] : '').$orderid; } $orderentrynotes=str_replace(" ","
",$row['memonotes']); $internalmemonotes=str_replace(" ","
",$row['internalmemonotes']); } if ($cid>'0' ) { include ("../crm/showaddress.php"); $sql = "SELECT * FROM viamedquotecontact WHERE COMPANY_ID = ? AND polog = 'on'"; //print "$sql
"; $stmt = pdoquery($sql, array($cid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $kemailaddressesto = isset ( $kemailaddressesto ) ? $kemailaddressesto : ''; $kemailaddressesto .= $row['INETADDR'].","; } $kemailaddressesto=substr($kemailaddressesto, 0, -1); $recipient = isset ( $recipient ) ? $recipient : ''; $subject = isset ( $subject ) ? $subject : '' ; $body = isset ( $body ) ? $body : '' ; $mailToLink = "mailto:$recipient?subject=$subject&body=$body"; $operadoc = isset ( $operadoc ) ? $operadoc : ''; $displaymaillink = operadoclinks($x,$operadoc,$float); $displaymaillink .= ''; $displaymaillink .= "Send Email to $kemailaddressesto
(Dont forget to attach the file and SET the from link in gmail

"; } $sql = "SELECT * FROM viamed_po_logs WHERE porref = ?"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $num = count($rows); if ($num==0) { $i="INSERT INTO viamed_po_logs (porref) VALUES (?)"; pdoquery($i, array($narrowpor)); //print "$i"; } $sql = "SELECT * FROM viamed_po_logs WHERE porref = ? AND stock_ref <> ''"; //print "$sql
"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk="a".$row['stock_ref']; $countline[$usestk] = (isset($countline[$usestk]) ? $countline[$usestk] : 0) + 1; $id=$row['contactid']; $contactid=$row['contactid']; $cid=$row['companyid']; $cidcompany=$row['companyid']; $pogenby=$row['pogenby']; $tsetby=$row['sentby']; $tsentvia=$row['sentvia']; $sconfby=$row['confirmedvia']; $tracknum=" - ".$row['tracknum']; $defaultship=$row['shipmethod']; } $pogenby = isset ( $pogenby ) ? $pogenby : 0 ; if ($pogenby==0) { $sql = "SELECT * FROM pw WHERE username = ?"; $stmt = pdoquery($sql, array($tsetby)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $pogenby=$row['id']; } } $genopts .= " "; $sql = "SELECT pw.id as id,pw.username as username FROM pw,pw_companys WHERE pw.active='1' AND pw.username<> '' AND pw.id=pw_companys.vui AND company_id='1' AND username<>'Training' AND username<>'Xhibition' ORDER BY pw.username"; $stmt = pdoquery($sql, array()); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $genopts .= ""; } $sql = "SELECT * FROM viamed_po_logs_est_ship WHERE po = ? ORDER BY estship DESC"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk=$row['stockref']; $prndate=date("d/m/y",$row['estship']); $multipleship[$usestk]="(".$row['estqty'].") on $prndate"; } // lets ensure we have the base data in the system! $sql = "SELECT * FROM supplier_items WHERE POR = ? ORDER BY OperaReference, Quantity_Required"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk="a".$row['OperaReference']; $countline2[$usestk] = (isset($countline2[$usestk]) ? $countline2[$usestk] : 0) + 1; if ((isset($countline[$usestk]) ? $countline[$usestk] : 0) < $countline2[$usestk]) { $i="INSERT INTO viamed_po_logs (porref,stock_ref,qty) VALUES (?, ?, ?)"; pdoquery($i, array($narrowpor, $row['OperaReference'], $row['Quantity_Required'])); //print "$i"; } } $sql = "SELECT * FROM viamed_po_logs WHERE porref = ?"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $pogenby=$row['pogenby']; $lineid=$row['id']; if ($row['confirmedvalidon']>0) { $lastvalidatedby[$lineid]=getusername($row['confirmedvalidby']); $lastvalidatedon[$lineid]=date("d M Y",$row['confirmedvalidon']); } else { $lastvalidatedby[$lineid]=''; $lastvalidatedon[$lineid]=''; } $linkcode=$row['id']; ?> fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $shipid=$row['id']; $shipmethod[$shipid]=$row['company']." ".$row['service']; } $sql = "SELECT * FROM viamedquote_global_watchlist WHERE addedby = ? AND watchkey1 = ?"; //print "$sql"; $stmt = pdoquery($sql, array($vui, $orderid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk=$row['watchkey2']; $watchitem[$usestk]=1; } $sql = "SELECT * FROM viamedquote_purchase_orders WHERE id = ?"; //print "$sql"; $stmt = pdoquery($sql, array($orderid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $supplierweblink=$row['supplierweblink']; $supplierweblinkmd5=$row['supplierweblinkmd5']; } $barcodessold = "
Barcodes Sales
"; $barcodessold .= ""; $sql = "SELECT count(*) as tot , Stock_ref ,Dateout , Invoicenumber , id FROM Serialnumbers WHERE Porref = ? AND Invoicenumber <> '' GROUP BY Stock_ref , Invoicenumber ORDER BY Dateout"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $num = count($rows); foreach ($rows as $row) { $stkref=$row['Stock_ref']; if (substr($row['Invoicenumber'],0,2)=='ID') { $barcodessold .= ""; if ($stkref != $laststk) { $laststk=$stkref; $acc=0; } $acc=$acc+$row['tot']; $datesent=date("d M Y",$row['Dateout']); $barcode=substr($row['Invoicenumber'],2); $invlinks=decodeinvoicenumberlinks($x,$row['Invoicenumber']); $uinv=decodeinvoicenumber($row['Invoicenumber']); $cid=isset($custid[$uinv]) ? $custid[$uinv] : ''; $barcodessold .= ""; $barcodessold .= ""; } else { $barcodessold .= ""; if ($stkref != $laststk) { $laststk=$stkref; $acc=0; } $acc=$acc+$row['tot']; $datesent=date("d M Y",$row['Dateout']); $invlinks=decodeinvoicenumberlinks($x,$row['Invoicenumber']); $uinv=decodeinvoicenumber($row['Invoicenumber']); $cid=isset($custid[$uinv]) ? $custid[$uinv] : ''; $barcodessold .= ""; $barcodessold .= ""; } } $barcodessold .= "
Stock refCustomerCIDCustomer RefQty SentDelivery NoteInvoice ReferenceDate Invoiced
$stkref".(isset($compn[$cid]) ? $compn[$cid] : '')." $cid".(isset($ucustr[$uinv]) ? $ucustr[$uinv] : '')."".linkbarcodehistory($x,$barcode)."$barcode (sample)Internal Merge$datesent
$stkref".(isset($compn[$cid]) ? $compn[$cid] : '')." $cid".(isset($ucustr[$uinv]) ? $ucustr[$uinv] : '')."".$row['tot']."".operadoclinks($x,$row['Invoicenumber'],'Delivery Notes')."".$row['Invoicenumber']."$invlinks$datesent
"; $lastcodestk=""; $barcodereceived = "
Barcodes Received
"; $barcodereceived .= ""; $sql = "SELECT count(*) as tot , Stock_ref ,DateBookedin ,Bookedinby FROM Serialnumbers where Porref=? group by Stock_ref,Datebookedin order by Stock_ref,Datebookedin"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $stkref=$row['Stock_ref']; $barcodereceived .= ""; if ($stkref != $laststk) { if ( $laststk <>'' ) { $barcodereceived .= ""; } $laststk=$stkref; $acc=0; } if ($lastcodestk==$stkref) { $acc=$acc+$row['tot']; } else { $acc=$row['tot']; } $lastcodestk=$stkref; $daterec=date("d M Y",$row['DateBookedin']); $supdesc[$stkref] = isset ( $supdesc[$stkref] ) ? $supdesc[$stkref] : '' ; $barcodereceived .= ""; $barcodereceived .= ""; } $barcodereceived .= "
Stock refSupplier RefQty ReceivedTotal RecDate ReceivedBooked in BySystem Allocations
 
$stkref".$supdesc[$stkref]."".$row['tot']."$acc$daterec".$row['Bookedinby']."
"; $sql = "SELECT * FROM viamedquote_purchase_orders where id=? and (company_id=? or company_id=?)"; //print "$sql
"; $stmt = pdoquery($sql, array($orderid, $cid, $cidcompany)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $hostcompanyid=$row['hostcompanyid']; $completedon=$row['completedon']; $cancelreason=$row['cancelreason']; $completedby=$row['completedby']; $createdby=getusername($row['addedby']); $createdbyid=$row['addedby']; $createdon=date("d M Y",$row['addedon']); $committedby=getusername($row['commitedby']); if ($row['commitedon'] >0) { $committedon=date("d M Y",$row['commitedon']); } else { $committedon='Not Committed'; } $internalnotes=$row['internalmemonotes']; } $sql = "SELECT * FROM viamed_customer_stock_references where companyid=? and hostcompanyid=? and (status='2' or status='-2')"; $stmt = pdoquery($sql, array($cid, $hostcompanyid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $ustk=$row['stock_ref']; $supdesc[$ustk]=$row['customer_ref']; } print "$narrowpor P.O. Log"; //print "$narrowpor"; $headerbreak = "

$global_company_logo48[$hostcompanyid] ".linkpurchaseorder($x,$narrowpor,'','')."$narrowpor

"; echo $headerbreak; echo $displaymaillink; if ($completedon>0) { print "

COMPLETED ORDER

".getusername($completedby)." $cancelreason"; } else { if ($usersecurity > 7 || $hostcompanyid==3) { print "

"; } } if ($orderentrynotes<>'') { print "
PaperworkMemo
$orderentrynotes

"; } if ($internalmemonotes<>''){ print "
Order Entry Notes
$internalmemonotes

"; } if ($internalnotes<>''){ print "
Internal Order Notes
$internalnotes
"; } print "

"; print "

Only update Changes leave all other Fields Blank
"; $sql = "SELECT stock_ref,OperaDescription FROM stocklist_tarriffs where hostcompany_id=?"; $stmt = pdoquery($sql, array($hostcompanyid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk=$row['stock_ref']; $stkdesc[$usestk]=$row['OperaDescription']; } $sql = "SELECT id FROM viamed_po_logs where porref=? and arriveshipdate >0"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $uselink=$row['id']; $uselanded[$uselink]="CHECKED"; } // NEw Selector print "
"; print "

ADD Paperwork Type
"; print ""; print ""; print ""; print ""; print ""; print ""; $msg ="
Description
Supplier Reference

"; print $msg; print "
"; $sql = "SELECT * FROM ISO_quality_manual_files where (description like ? or Porref=? or purchaseorderid=?) and archived='' order by id desc"; $stmt = pdoquery($sql, array("%$narrowpor%", $narrowpor, $orderid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $num = count($rows); if ($num>0 ) { print "Uploaded Documents:
"; foreach ($rows as $row) { print ""; } print "
LinksAddedDocIDUploaded BYDescription
".linkdocid($x,$row['docid'])."".prndate($row['addedon'])."".$row['docid']."".$row['addedby']."".$row['description']."
"; } print "
"; ?>
"; print ""; if ($createdbyid==$vui || $vui==1 || $vui==2) { print ""; } print ""; print ""; print ""; print ""; if ($tsetby=='') { ?> "; } ?> "; print ""; print ""; print ""; print ""; print ""; print ""; //print ""; print " "; print ""; print "
Order Created by$createdby
Order Created on$createdon
Order Committed by$committedby
Order Committed on$committedon
Order sent by
Order Sent Via / Ordered Sent Via$tsentvia
Order Confirmed
Supplier is Part Shipping Order &po=">Enter Details
Estimated Full PO Shipping Date (Ship TO Viamed)
Our Required Date
$prnourdate"; print "
"; ?>
Supplier Confirmation Number
Supplier Tracking Number $tracknum
Supplier Tracking WebLink
Actual Rec Ship Method"; $sql = "SELECT * FROM viamed_shipping_options"; $stmt = pdoquery($sql, array()); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $currryid=$row['id']; $shipperwas[$currryid]=$row['company']; } $sql = "SELECT * FROM viamed_goodsinbook where contactname like ? order by bookinon"; $stmt = pdoquery($sql, array("%$narrowpor%")); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $currryid=$row['courier']; $landeddate=date("d M Y",$row['bookinon']); print "$shipperwas[$currryid] Landed : $landeddate
"; } print "
"; echo $headerbreak; $sql = "SELECT * FROM viamedquote_purchase_orders_details where orderid=?"; //print "$sql
"; $stmt = pdoquery($sql, array($orderid)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $lineid=$row['id']; $sst=$row['stockref']; $supplierstatus[$lineid]=$row['monday_input_status']; $suppliershipdate[$lineid]=$row['monday_input_shipdate']; $qtyordered[$lineid]=$row['qty']; $qtyrec[$lineid]=$row['qty_received']; $ordertotalrecieved[$sst] = isset ( $ordertotalrecieved[$sst] ) ? $ordertotalrecieved[$sst] : 0 ; $ordertotalrecieved[$sst]=$ordertotalrecieved[$sst]+$row['qty_received']; $deliveryconfirmedreal[$lineid]=$row['confirmeddeliverdate']; $deliveryconfirmedrealby[$lineid]=$row['confirmeddeliverdateby']; $tracking[$lineid]=$row['trackingnumber']; if ($row['requireddate'] > 0 ) { $requireddate[$lineid]=date("d M Y",$row['requireddate']); } else { $requireddate[$lineid]=""; } } print ""; if ($usersecurity > 7 and 1==2) { print ""; } print ""; $sql = "SELECT count(*) as recq , po_lineid FROM Serialnumbers where Ordernumber<>'o' and Porref=? group by po_lineid"; //print "$sql
"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $lineid=$row['po_lineid']; $qtyrec[$lineid]=$row['recq']; } $sql = "SELECT id, orderdetailid, stock_ref, qty, estshipdate, notes, shipmethod, confirmnumber FROM viamed_po_logs where porref=? and stock_ref<>''"; //print "$sql
"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk=$row['stock_ref']; $lineid=$row['orderdetailid']; $qtyrec[$lineid] = isset($qtyrec[$lineid]) ? $qtyrec[$lineid] : 0; $requireddate[$lineid] = isset($requireddate[$lineid]) ? $requireddate[$lineid] : ''; print ""; $linkcode=$row['id']; $stkdesc[$usestk] = isset ( $stkdesc[$usestk] ) ? $stkdesc[$usestk] : '' ; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; if ($usersecurity > 7 ) { $supplierstatus[$lineid] = isset($supplierstatus[$lineid]) ? $supplierstatus[$lineid] : ''; $suppliershipdate[$lineid] = isset($suppliershipdate[$lineid]) ? $suppliershipdate[$lineid] : ''; print ""; } print ""; if ($usersecurity > 7 and 1==2) { print ""; } print ""; } print "
Line IDStock ReferenceDescriptionQuantityRequiredReceived Est Ship To Viamed DateNotes "; ?> ">(History) Ship MethodSupplier ConfirmationWatchValidatedRevalidateSupplier StatusSupplier ShipPO Received
$lineid".linkstkref($x,$usestk,$float,$size,$hostcompanyid) ."$usestk".$stkdesc[$usestk]." ".$row['qty']."
$requireddate[$lineid]$qtyrec[$lineid]"; print ""; if ($row['estshipdate']>0) { $prndate=date("d-m-Y",$row['estshipdate']); } else { $prndate=""; } $tracking[$lineid] = isset($tracking[$lineid]) ? $tracking[$lineid] : ''; ?> Date:" name='' value=''>
Tracking: id='' onchange="updatetracking('')"> "; $deliveryconfirmedreal[$lineid] = isset($deliveryconfirmedreal[$lineid]) ? $deliveryconfirmedreal[$lineid] : 0; if ($deliveryconfirmedreal[$lineid]==1) { print ""; } else{ print ""; } print ""; $multipleship[$usestk] = isset ( $multipleship[$usestk] ) ? $multipleship[$usestk] : '' ; print "
$multipleship[$usestk]"; print ""; print ""; print ""; print " "; print ""; print ""; //print ""; print "$lastvalidatedon[$linkcode] $lastvalidatedby[$linkcode]
"; print "
$supplierstatus[$lineid]$suppliershipdate[$lineid]
Fix $lineid

"; print "
"; print "
"; print $barcodereceived; $sql = "SELECT viamedquote_orders_invoices_details.invoiceref , viamedquote_orders.customer_ref , viamedquote_orders.company_id FROM Serialnumbers,viamedquote_orders_invoices_details,viamedquote_orders where viamedquote_orders_invoices_details.barcode=Serialnumbers.id AND Serialnumbers.Porref=? and Serialnumbers.Invoicenumber<>'' AND viamedquote_orders_invoices_details.orderid=viamedquote_orders.id GROUP BY viamedquote_orders.id,viamedquote_orders_invoices_details.invoiceref"; //print "$sql
"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $uinv=$row['invoiceref']; $ucustr[$uinv]=$row['customer_ref']; $custid[$uinv]=$row['company_id']; } $sql = "SELECT ID,COMPANY FROM viamedquoteaddress"; $stmt = pdoquery($sql, array()); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $cid=$row['ID']; $compn[$cid]=$row['COMPANY']; } print $barcodessold; $laststkref="-1"; print "
Updates
"; // bottom display print ""; print ""; } print ""; $laststkref = $usestk; } print "
Stock RefSent ViaSent ByRequiredConfirmed OnConfirmed ViaConfirmed ByEstimated Ship DateConfirmation NumberNotes
"; $sql = "SELECT * FROM viamed_po_logs where porref = ? and stock_ref <> '' order by stock_ref"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $usestk=$row['stock_ref']; $uselink=$narrowpor."zxz".$usestk; if ($row['confirmeddate']>'1') { $confimon=date("d/m/y",$row['confirmeddate']); } else { $confimon=""; } if ($row['estshipdate']>'1') { $estmon=date("d/m/y",$row['estshipdate']); } else { $estmon=""; } print "
".linkstkref($x,$usestk,$float,$size,$hostcompanyid); if ($row['pogenby']<1) { $dsentby=$row['sentby']; } else { $dsentby=getusername($row['pogenby']); } print $row['stock_ref'].''.$row['sentvia'].''.$dsentby.''.$requireddate[$lineid].''.$confimon.''.$row['confirmedvia'].''.$row['confirmedby'].''.$estmon; print ""; $shipmethodid=$row['shipmethod']; $shipmethod[$shipmethodid] = isset ( $shipmethod[$shipmethodid] ) ? $shipmethod[$shipmethodid] : '' ; print "$shipmethod[$shipmethodid]"; print $row['confirmnumber'].''; if ($row['notes']<>'') { $prnstring=$row['notes']; if (strlen($prnstring)>40) { $prnstring=substr($prnstring,0,40); $prnstring=$prnstring."... "; print "$prnstring
More
"; } else { print "$prnstring"; } } if ($row['id']==$more) { print "
NOTES: ".$row['stock_ref']."".$row['notes']."
"; print "
History of Changes
"; print ""; $sql = "SELECT * FROM viamed_po_logs_history where porref = ? order by id desc"; //print "$s
"; $stmt = pdoquery($sql, array($narrowpor)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { print ""; $cdate=date("d M Y",$row['confirmeddate']); $estshipd=date("d M Y",$row['estshipdate']); if ($row['nextupdatedate'] > 1 ) { $update=date("d M Y",$row['nextupdatedate']); } else { $update = ''; } print ""; print ""; } print "
|".$row['stock_ref']."".$row['sentvia']."".$row['sentby']."$cdate cv ".$row['confirmedvia']."".$row['confirmedby']."$estshipd".$row['donotchase']."".$row['notes']."$update".$row['nextupdateby']."
"; ?>