var $mfrom_san; # NOTES_ a string, the SAN of the store where the order is being sent. var $mto_san; # NOTES_ a string, "SAN" (not an actual san) of the customer making the order. user sans are u with the user id appended. e.g. u12345 var $cfrom; # NOTES_ contact object corresponding to STORE var $cto; # NOTES_ contact object corresponding CUSTOMER var $isa_num; # NOTES_ at most 9 digits number. is identical to the bookorder id. it should uniquely identify an online order. in some cases, should be sprintf'd as %09d (0 padded) var $gs_num; # NOTES_ gs num is the same number as isa_num var $shiptype; # NOTES_ a string. will be: either pickup or ship or quote $this->gs_num=$this->isa_num; # NOTES_ GS number is assigned the bookorder row id $curdate=date("Ymd"); # NOTES_ date in yyyymmdd format $curtime=date("Hi"); # NOTES_ time in 24-hour hhmm format sprintf("ISA*00*TBMWEBSTOR*00* *ZZ*%-15.15s*ZZ*%-15.15s*%s*%s*U*00200*%09d*0*P*>\n",$this->mto_san,$this->mfrom_san,date("ymd"),$curtime,$this->isa_num); # NOTES_ all hardcoded fields (like TBMWEBSTOR, ZZ, 00200, etc) here are intended as is. sprintf("GS*PO*%s*%s*%s*%s*%d*X*004010\n",$this->mto_san,$this->mfrom_san,$curdate,$curtime,$this->gs_num); # NOTES_ Group Start. all hardcoded values are intended as is sprintf("ST*850*0001\n"); # NOTES_ Segment Start. all hardcoded values are intended as is sprintf("BEG*00*NE*%s**%s*OL%s*AC\n",((strlen($this->ponum)>0)?($this->ponum):("OL".$this->isa_num)),$curdate,$this->isa_num); # NOTES_ ponum is a string that is usually a purchase order number. this is not required, it is set by the user making the order for their own purposes. here we use ponum if it set, else we use OL + $this->isa_num (OL meaning OnLine) $recombined_notes .= "NTE*INT*".substr($wline,0,60)."\n"; # NOTES_ there may be multiple NTE (note) lines, but each line is to be no longer than 60 chars. these are notes by the customer intended for the person handling the online order. $stseg .= "CSH*O\n"; # NOTES_ this means to back order the books if OS (Out of Stock) or NYP (Not Yet Published) $stseg .= "DTM*001*20050611\n"; # NOTES_ from eric: can't remember what this field means. might as well just leave it in. xxx date + a month? 2? sprintf("N1*VN*%s*15*%s\n",strip_accents($this->cfrom->getName()),$this->mfrom_san); # NOTES_ 15 means next item will be a san, the VN (vendor) sprintf("N3*%s*%s\n",strip_accents($this->cfrom->getAddr1()),strip_accents($this->cfrom->getAddr2())); # NOTES_ vendor address 1 and 2 sprintf("N4*%s*%s*%s*%s**\n",strip_accents($this->cfrom->getCity()),$this->cfrom->getProv(),$this->cfrom->getPostal(),conv_country_to_countrycode($this->cfrom->getCountry())); # NOTES_ more vendor fields. country code is e.g. US or CA sprintf("N1*BT*%s*15*%s\n",strip_accents($this->cto->getName()),$this->mto_san); # NOTES_ BT = bill to (customer) name and "san" sprintf("N3*%s*%s\n",strip_accents($this->cto->getAddr1()),strip_accents($this->cto->getAddr2())); # NOTES_ bill to customer address info sprintf("N4*%s*%s*%s*%s**\n",strip_accents($this->cto->getCity()),strip_accents($this->cto->getProv()),$this->cto->getPostal(),conv_country_to_countrycode($this->cto->getCountry())); # NOTES_ billto customer info sprintf("N1*ST*%s*15*%s\n",strip_accents($this->cto->getName()),$this->mto_san); # NOTES_ ship-to information is the same as billto information sprintf("N3*%s*%s\n",strip_accents($this->cto->getAddr1()),strip_accents($this->cto->getAddr2())); # NOTES_ ship-to address sprintf("N4*%s*%s*%s*%s**\n",strip_accents($this->cto->getCity()),$this->cto->getProv(),$this->cto->getPostal(),conv_country_to_countrycode($this->cto->getCountry())); # NOTES_ ship-to address "TD5****T*401 Ship\n"; # NOTES_ use only ONE TD5 row depending on order type "TD5****H*405 Pickup\n"; # NOTES_ use only ONE TD5 row depending on order type "TD5****H*000 Quote\n"; # NOTES_ use only ONE TD5 row depending on order type sprintf("PER*OD*%s*TE*%s\n",$contactname,$this->cto->getPhone()); # NOTES_ contactname is the customer's contact name (for example, if John Doe is ordering for a school or business). TE = telephone number sprintf("PER*OD*%s*FX*%s\n",$contactname,$this->cto->getFax()); # NOTES_ FX = fax number sprintf("PER*OD*%s*EM*%s\n",$contactname,$this->cto->getEmail()); # NOTES_ EM = email address sprintf("PO1*%s*%d*UN*%s*SR*%s\n",$ct->getLinepo(),$row['qty'],$ct->getCa_cust_retail(),join('*',$keytypes)); # NOTES_ getLinepo is a per-line-item purchase order string, set by the customer, not required, may be blank. qty is item quantity. keytypes is an array of the identifying keys for this item. at least 1 is required. may be: EN*9780123456786 (for EAN) or UP*012345678905 (for UPC) or VN*ABCD1234 for anything that is neither EAN nor UPC. (Vendor Number) sprintf("CTP**SLP*%s***DIS*%.4f\n",$ct->getCa_cust_retail(),sprintf("%.4f",(100-$ct->getCa_cust_disc())/100)); # NOTES_ getCa_cust_retail is the price BEFORE the discount. e.g. 32.00 discount is calculated such that for example a 20% discount will be represented as 0.8000 (4 digits after the decimal place is intentional for penny-precision). in this example the book costs 25.60 (32.00 minus 20%) sprintf("PID*F****%s\n",$to->getTitle()); # NOTES_ this line is just for the title sprintf("PWK*******%s,%s,%d,%.2f,%.2f,%s,%s,%s,%s*\n", $v->getSupplier_loc(),$v->getOrder_group(),$v->getQty(),$v->getCa_cust_retail(),$v->getPubprice(),$_discount,$v->getCa_shipto(),$v->getLinepo(),$ms_qty_s); # NOTES_ for PWK row, getSupplier_loc will be the store san. getOrder_group is blank for all customer orders. getPubprice will be the store's price, so 32.00 like the example above. $_discount may be left as 0. getCa_shipto may be left as blank. getLinepo is described above. $ms_qty_s should be blank for customer orders. $this_po_chunk .= sprintf("NTE*ORD*%s\n",$this->stripNotes($n['order_notes'])); # NOTES_ user-supplied order notes stripped of all newlines/carriage returns. omit this line if there are no notes. sprintf("CTT*%d*%d\n",count($items),$total_items); # NOTES_ totals. count($items) is count of unique isbns (the number of PO1 lines), and $total_items is the sum of the quantities ordered sprintf("SE*%s*0001\n",$stseg_count); # NOTES_ segment end. $stseg_count is the number of lines between, *and including*, the ST*/SE* lines (segment headers/footers) sprintf("GE*1*%d\n",$this->gs_num); # NOTES_ group end. gs_num is bookorder id. sprintf("IEA*1*%09d\n",$this->isa_num); # NOTES_ end. isa_num is bookorder id.