PageRenderTime 65ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/application/views/pages/admin/email.php

https://bitbucket.org/chadsaun/ifrogz-panel
PHP | 737 lines | 610 code | 48 blank | 79 comment | 156 complexity | 295567573e6a636d51a4f8c8e5c1fece MD5 | raw file
  1. <?php
  2. include('init.php');
  3. if ( ! defined('KOHANA_EXTERNAL_MODE')) {
  4. define('KOHANA_EXTERNAL_MODE', TRUE);
  5. }
  6. include_once(DOCROOT.'index.php');
  7. //This code is copyright (c) Internet Business Solutions SL, all rights reserved.
  8. //The contents of this file are protect under law as the intellectual property of Internet
  9. //Business Solutions SL. Any use, reproduction, disclosure or copying of any kind
  10. //without the express and written permission of Internet Business Solutions SL is forbidden.
  11. //Author: Vince Reid, vince@virtualred.net
  12. //HCS - DRE 03/06/2005 Gift Cert Mod START
  13. function bus_days($days_to_add) {
  14. $start_date = strtotime(date("Y-m-d"));
  15. $workdays_only = true;
  16. $skip_holidays = true;
  17. $seconds_in_a_day = 86400;
  18. $sunday_val = "0";
  19. $saturday_val = "6";
  20. $holiday_array = array();
  21. $ptr_year = intval(date("Y", $start_date));
  22. $holiday_array[$ptr_year] = get_holidays(date("Y",$start_date));
  23. //showarray($holiday_array); exit();
  24. $cur_day = $start_date;
  25. while($days_to_add > 0) {
  26. $cur_day += $seconds_in_a_day;
  27. $day_of_week = date("w",$cur_day);
  28. //echo date("Y-m-d H:i:s",$cur_day).' '.$days_to_add.'<br />';
  29. if($workdays_only) {
  30. if(($day_of_week != $sunday_val) && ($day_of_week != $saturday_val)) {
  31. if($skip_holidays) {
  32. if(intval(date("Y", $cur_day)) != $ptr_year){
  33. $ptr_year = intval(date("Y", $cur_day));
  34. $holiday_array[$ptr_year] = get_holidays(date("Y", $cur_day));
  35. }
  36. if(!in_array($cur_day, $holiday_array[date("Y", $cur_day)])){
  37. $days_to_add--;
  38. }
  39. }else{
  40. $days_to_add--;
  41. }
  42. }
  43. }else{
  44. if($skip_holidays){
  45. if(intval(date("Y", $cur_day))!=$ptr_year){
  46. $ptr_year = intval(date("Y", $cur_day));
  47. $holiday_array[$ptr_year] = get_holidays(date("Y", $cur_day));
  48. }
  49. if(!in_array($cur_day, $holiday_array[date("Y", $cur_day)])){
  50. $days_to_add--;
  51. }
  52. }else{
  53. $days_to_add--;
  54. }
  55. }
  56. }
  57. return $cur_day;
  58. }
  59. /**
  60. * Takes a date in yyyy-mm-dd format and returns a PHP timestamp
  61. *
  62. * @param string $MySqlDate
  63. * @return unknown
  64. */
  65. function get_timestamp($MySqlDate){
  66. $date_array = explode("-",$MySqlDate); // split the array
  67. $var_year = $date_array[0];
  68. $var_month = $date_array[1];
  69. $var_day = $date_array[2];
  70. $var_timestamp = mktime(0,0,0,$var_month,$var_day,$var_year);
  71. return($var_timestamp); // return it to the user
  72. }
  73. /**
  74. * Returns the date of the $ord $day of the $month.
  75. * For example ordinal_day(3, 'Sun', 5, 2001) returns the
  76. * date of the 3rd Sunday of May (ie. Mother's Day).
  77. *
  78. * @author heymeadows@yahoo.com
  79. *
  80. * @param int $ord
  81. * @param string $day (must be 3 char abbrev, per date("D);)
  82. * @param int $month
  83. * @param int $year
  84. * @return unknown
  85. */
  86. function ordinal_day($ord, $day, $month, $year) {
  87. $firstOfMonth = get_timestamp("$year-$month-01");
  88. $lastOfMonth = $firstOfMonth + date("t", $firstOfMonth) * 86400;
  89. $dayOccurs = 0;
  90. for ($i = $firstOfMonth; $i < $lastOfMonth ; $i += 86400){
  91. if (date("D", $i) == $day){
  92. $dayOccurs++;
  93. if ($dayOccurs == $ord){
  94. $ordDay = $i;
  95. }
  96. }
  97. }
  98. return $ordDay;
  99. }
  100. function memorial_day($inc_year){
  101. for($date_stepper = intval(date("t", strtotime("$inc_year-05-01"))); $date_stepper >= 1; $date_stepper--){
  102. if(date("l", strtotime("$inc_year-05-$date_stepper"))=="Monday"){
  103. return strtotime("$inc_year-05-$date_stepper");
  104. break;
  105. }
  106. }
  107. }
  108. /**
  109. * Looks through a lists of defined holidays and tells you which
  110. * one is coming up next.
  111. *
  112. * @author heymeadows@yahoo.com
  113. *
  114. * @param int $inc_year The year we are looking for holidays in
  115. * @return array
  116. */
  117. function get_holidays($inc_year){
  118. //$year = date("Y");
  119. $year = $inc_year;
  120. $holidays[] = new Holiday("New Year's Day", get_timestamp("$year-1-1"));
  121. //$holidays[] = new Holiday("Australia Day", get_timestamp("$year-1-26"));
  122. $holidays[] = new Holiday("Labour Day", ordinal_day(1, 'Mon', 3, $year));
  123. //$holidays[] = new Holiday("Anzac Day", get_timestamp("$year-4-25"));
  124. //$holidays[] = new Holiday("St. Patrick's Day", get_timestamp("$year-3-17"));
  125. // TODO: $holidays[] = new Holiday("Good Friday", easter_date($year));
  126. $holidays[] = new Holiday("Easter", easter_date($year));
  127. // TODO: $holidays[] = new Holiday("Easter Monday", easter_date($year));
  128. //$holidays[] = new Holiday("Foundation Day", ordinal_day(1, 'Mon', 6, $year));
  129. //$holidays[] = new Holiday("Queen's Birthday", ordinal_day(1, 'Mon', 10, $year));
  130. $holidays[] = new Holiday("Memorial Day", memorial_day($year));
  131. //$holidays[] = new Holiday("Mother's Day", ordinal_day(2, 'Sun', 5, $year));
  132. //$holidays[] = new Holiday("Father's Day", ordinal_day(3, 'Sun', 6, $year));
  133. $holidays[] = new Holiday("Independence Day", get_timestamp("$year-7-4"));
  134. $holidays[] = new Holiday("Pioneer Day", get_timestamp("$year-7-24"));
  135. $holidays[] = new Holiday("Labor Day", ordinal_day(1, 'Mon', 9, $year));
  136. $holidays[] = new Holiday("Thanksgiving Day", ordinal_day(4, 'Thu', 11, $year));
  137. $holidays[] = new Holiday("Day after Thanksgiving", ordinal_day(4, 'Fri', 11, $year));
  138. //$holidays[] = new Holiday("Christmas Eve", get_timestamp("$year-12-24"));
  139. $holidays[] = new Holiday("Christmas", get_timestamp("$year-12-25"));
  140. //$holidays[] = new Holiday("Boxing Day", get_timestamp("$year-12-26"));
  141. $holidays[] = new Holiday("New Years Eve", get_timestamp("$year-12-31"));
  142. $numHolidays = count($holidays);
  143. $out_array = array();
  144. for ($i = 0; $i < $numHolidays; $i++){
  145. $out_array[] = $holidays[$i]->date;
  146. }
  147. unset($holidays);
  148. return $out_array;
  149. }
  150. class Holiday{
  151. //var $name;
  152. //var $date;
  153. var $name;
  154. var $date;
  155. // Contructor to define the details of each holiday as it is created.
  156. function holiday($name, $date){
  157. $this->name = $name; // Official name of holiday
  158. $this->date = $date; // UNIX timestamp of date
  159. }
  160. }
  161. //HCS - DRE 03/06/2005 Gift Cert Mod STOP
  162. function vrhmac($key, $text){
  163. $idatastr = " ";
  164. $odatastr = " ";
  165. $hkey = (string)$key;
  166. $idatastr .= $text;
  167. for($i=0; $i<64; $i++){
  168. $idata[$i] = $ipad[$i] = 0x36;
  169. $odata[$i] = $opad[$i] = 0x5C;
  170. }
  171. for($i=0; $i< strlen($hkey); $i++){
  172. $ipad[$i] ^= ord($hkey{$i});
  173. $opad[$i] ^= ord($hkey{$i});
  174. $idata[$i] = ($ipad[$i] & 0xFF);
  175. $odata[$i] = ($opad[$i] & 0xFF);
  176. }
  177. for($i=0; $i< strlen($text); $i++){
  178. $idata[64+$i] = ord($text{$i}) & 0xFF;
  179. }
  180. for($i=0; $i< strlen($idatastr); $i++){
  181. $idatastr{$i} = chr($idata[$i] & 0xFF);
  182. }
  183. for($i=0; $i< strlen($odatastr); $i++){
  184. $odatastr{$i} = chr($odata[$i] & 0xFF);
  185. }
  186. $innerhashout = md5($idatastr);
  187. for($i=0; $i<16; $i++)
  188. $odatastr .= chr(hexdec(substr($innerhashout,$i*2,2)));
  189. return md5($odatastr);
  190. }
  191. function order_success($sorderid,$sEmail,$sendstoreemail){
  192. do_order_success($sorderid,$sEmail,$sendstoreemail,TRUE,TRUE,TRUE,TRUE);
  193. }
  194. function do_order_success($sorderid,$sEmail,$sendstoreemail,$doshowhtml,$sendcustemail,$sendaffilemail,$sendmanufemail){
  195. global $maintablebg,$innertablebg,$maintablewidth,$innertablewidth,$maintablespacing,$innertablespacing,$maintablepadding,$innertablepadding,$thereference,$emlNl,$htmlemails,$extraorderfield1,$extraorderfield2,$shipType,$emailheader,$emailfooter,$emailencoding,$hideoptpricediffs,$xxWtIns,$ordGrandTotal,$ordID,$digidownloads,$dropshipfooter,$dropshipheader,$digidownloademail;
  196. global $xxHndlg,$xxDscnts,$xxOrdId,$xxCusDet,$xxEmail,$xxPhone,$xxShpDet,$xxShpMet,$xxAddInf,$xxPrId,$xxPrNm,$xxQuant,$xxUnitPr,$xxOrdTot,$xxStaTax,$xxCntTax,$xxShippg,$xxGndTot,$xxOrdStr,$xxTnxOrd,$xxTouSoo,$xxAff1,$xxAff2,$xxAff3,$xxThnks,$xxThkYou,$xxRecEml,$storeurl,$xxHomeURL,$xxCntShp,$success,$ordAuthNumber,$orderText,$ordTotal,$customheaders,$digidownloadsecret,$useaddressline2,$xxTouSooShipping,$xxTouSooDate,$xxTwoOrdIds;
  197. if(@$htmlemails==TRUE) $emlNl = "<br />"; else $emlNl="\n";
  198. if(@$customheaders == ""){
  199. $customheaders = "MIME-Version: 1.0\n";
  200. $customheaders .= "From: %from% <%from%>\n";
  201. //$customheaders .= "To: " . $custEmail . " <" . $custEmail . ">\n";
  202. if(@$htmlemails==TRUE)
  203. $customheaders .= "Content-type: text/html; charset=".$emailencoding."\n";
  204. else
  205. $customheaders .= "Content-type: text/plain; charset=".$emailencoding."\n";
  206. }
  207. $affilID = "";
  208. $saveHeader = "";
  209. $ordID = $sorderid;
  210. $hasdownload=FALSE;
  211. $ndropshippers=0;
  212. //HCS - DRE 03/07/05 Gift Cert Mod START
  213. $strsql = "SELECT * FROM orders WHERE ordID =".$ordID." AND ordStatus >= 3";
  214. $result = mysql_query($strsql);
  215. if($rs=mysql_fetch_assoc($result)) {
  216. $certstr = create_certificate($ordID);
  217. }else{
  218. $prodarray = array();
  219. $certorder = FALSE;
  220. $strsql = "SELECT pID FROM products WHERE p_iscert > 0";
  221. $result = mysql_query($strsql);
  222. while ($rs=mysql_fetch_assoc($result)) {
  223. $prodarray[] = $rs['pID'];
  224. }
  225. $prodarray = "'".implode("','",$prodarray)."'";
  226. if($prodarray == "") $prodarray = "NOVALIDPRODIDFORTHISQUERY696986";
  227. $strsql = "SELECT cartProdID FROM cart, orders WHERE ordID =".$ordID." AND cartOrderID =".$ordID." AND cartProdID IN (".$prodarray.")";
  228. $result = mysql_query($strsql);
  229. if(mysql_num_rows($result) > 0) $certorder = TRUE;
  230. }
  231. $strsql2 = "SELECT pend_order_amt, cert_amt, cert_exp_dt, cert_id, cert_code FROM certificates WHERE pend_order_id =".$ordID;
  232. $result2 = mysql_query($strsql2);
  233. $pendingamt = 0;
  234. $remainbal = 0;
  235. $certexpdt = 0;
  236. $certid = 0;
  237. $certcode = 0;
  238. $certend = "";
  239. if($rs2=mysql_fetch_assoc($result2)) {
  240. $pendingamt = $rs2['pend_order_amt'];
  241. $remainbal = $rs2['cert_amt'] - $rs['pend_order_amt'];
  242. $certexpdt = $rs2['cert_exp_dt'];
  243. $certid = $rs2['cert_id'];
  244. $certcode = $rs2['cert_code'];
  245. $certend = "#".substr($certcode, strlen($certcode)- 4, 4);
  246. $strsql = "UPDATE certificates SET cert_amt = cert_amt - pend_order_amt WHERE pend_order_id =".$ordID;
  247. mysql_query($strsql);
  248. $strsql = "UPDATE certificates SET pend_order_amt = 0, pend_order_id = 0 WHERE pend_order_id =".$ordID;
  249. mysql_query($strsql);
  250. // $strsql = "DELETE certificates WHERE cert_amt <= 0";
  251. // mysql_query($strsql);
  252. $strsql = "UPDATE orders SET ord_cert_id=".$certid.", ord_cert_amt=".$pendingamt." WHERE ordID =".$ordID;
  253. mysql_query($strsql);
  254. }
  255. //HCS - DRE 03/07/05 Gift Cert Mod STOP
  256. // GET DELIVERY DATE
  257. $delivery = getDeliveryDate($ordID);
  258. $sSQL = "SELECT ordID,ordName,ordAddress,ordAddress2,ordCity,ordState,ordZip,ordCountry,ordEmail,ordPhone,ordShipName,ordShipAddress,ordShipAddress2,ordShipCity,ordShipState,ordShipZip,ordShipCountry,ordPayProvider,ordAuthNumber,ordTotal,ordDate,ordStateTax,ordCountryTax,ordHSTTax,ordHandling,ordShipping,ordAffiliate,ordDiscount,ordDiscountText,ordComLoc,ordExtra1,ordExtra2,ordSessionID,ordAddInfo,ordShipType,payProvID FROM orders LEFT JOIN payprovider ON payprovider.payProvID=orders.ordPayProvider WHERE ordAuthNumber<>'' AND ordID='" . mysql_real_escape_string($sorderid) . "'";
  259. $result = mysql_query($sSQL) or print(mysql_error());
  260. if(mysql_num_rows($result) > 0){
  261. $rs = mysql_fetch_assoc($result);
  262. $orderText = "";
  263. $success=TRUE;
  264. $orderID2 = $rs["ordID"];
  265. $ordAuthNumber = $rs["ordAuthNumber"];
  266. $ordSessionID = $rs["ordSessionID"];
  267. $payprovid = $rs["payProvID"];
  268. if(@$emailheader != "") $saveHeader .= $emailheader;
  269. eval('global $emailheader' . $payprovid . ';$emailheader = @$emailheader' . $payprovid . ';');
  270. if(@$emailheader != "") $saveHeader .= $emailheader;
  271. if(!empty($_SESSION['neworderID'])) {
  272. $orderText .= $xxTwoOrdIds . $emlNl;
  273. $orderText .= $xxOrdId . ": " . $rs["ordID"] .', '.$_SESSION['neworderID']. $emlNl;
  274. } else $orderText .= $xxOrdId . ": " . $rs["ordID"] . $emlNl;
  275. if($thereference != "") $orderText .= "Transaction Ref" . ": " . $thereference . $emlNl;
  276. $orderText .= $xxCusDet . ": " . $emlNl;
  277. if(trim(@$extraorderfield1)!="") $orderText .= $extraorderfield1 . ": " . $rs["ordExtra1"] . $emlNl;
  278. $orderText .= $rs["ordName"] . $emlNl;
  279. $orderText .= $rs["ordAddress"] . $emlNl;
  280. if(@$useaddressline2==TRUE && trim($rs["ordAddress2"]) != '') $orderText .= $rs["ordAddress2"] . $emlNl;
  281. $orderText .= $rs["ordCity"] . ", " . $rs["ordState"] . $emlNl;
  282. $orderText .= $rs["ordZip"] . $emlNl;
  283. $orderText .= $rs["ordCountry"] . $emlNl;
  284. $orderText .= $xxEmail . ": " . $rs["ordEmail"] . $emlNl;
  285. $custEmail = $rs["ordEmail"];
  286. $orderText .= $xxPhone . ": " . $rs["ordPhone"] . $emlNl;
  287. if(trim(@$extraorderfield2)!="") $orderText .= $extraorderfield2 . ": " . $rs["ordExtra2"] . $emlNl;
  288. if(trim($rs["ordShipName"]) != "" || trim($rs["ordShipAddress"]) != ""){
  289. $orderText .= $xxShpDet . ": " . $emlNl;
  290. $orderText .= $rs["ordShipName"] . $emlNl;
  291. $orderText .= $rs["ordShipAddress"] . $emlNl;
  292. if(@$useaddressline2==TRUE && trim($rs["ordShipAddress2"]) != '') $orderText .= $rs["ordShipAddress2"] . $emlNl;
  293. $orderText .= $rs["ordShipCity"] . ", " . $rs["ordShipState"] . $emlNl;
  294. $orderText .= $rs["ordShipZip"] . $emlNl;
  295. $orderText .= $rs["ordShipCountry"] . $emlNl;
  296. }
  297. $ordShipType = $rs["ordShipType"];
  298. if($ordShipType != ""){
  299. $orderText .= $emlNl . $xxShpMet . ": " . $ordShipType;
  300. $orderText .= $emlNl . "Estimated Delivery Date: " . date("M j, Y",$delivery['deliveryDate']);
  301. if($delivery['extended'] > 0) {
  302. if($delivery['messageToUse'] == 'custom screen') {
  303. $orderText .= $emlNl . "Your order contains a custom screen. It should take an additional " . $delivery['extended'] . " business days to produce your custom screen before your order will ship.";
  304. }elseif($delivery['messageToUse'] == 'stock') {
  305. $orderText .= $emlNl . "Your order contains a back-ordered item. It should take an additional " . $delivery['extended'] . " business days before your order will ship.";
  306. }
  307. $orderText .= $emlNl . "Once your order ships it will ship via " . $delivery['method'] . " and will take " . $delivery['days_to_arrive'] . " business days to arrive.";
  308. }
  309. if(($rs["ordComLoc"] & 2)==2) $orderText .= $xxWtIns;
  310. $orderText .= $emlNl;
  311. }
  312. $ordAddInfo = trim($rs["ordAddInfo"]);
  313. if($ordAddInfo != ""){
  314. $orderText .= $emlNl . $xxAddInf . ": " . $emlNl;
  315. $orderText .= $ordAddInfo . $emlNl;
  316. }
  317. $ordTotal = $rs["ordTotal"];
  318. $ordDate = $rs["ordDate"];
  319. $ordStateTax = $rs["ordStateTax"];
  320. $ordDiscount = $rs["ordDiscount"];
  321. $ordDiscountText = $rs["ordDiscountText"];
  322. $ordCountryTax = $rs["ordCountryTax"];
  323. $ordHSTTax = $rs["ordHSTTax"];
  324. $ordShipping = $rs["ordShipping"];
  325. $ordHandling = $rs["ordHandling"];
  326. $affilID = trim($rs["ordAffiliate"]);
  327. }else{
  328. $orderText = "Cannot find customer details for order id: " . $sorderid . $emlNl;
  329. $sendstoreemail=FALSE;
  330. $sendcustemail=FALSE;
  331. $sendaffilemail=FALSE;
  332. $sendmanufemail=FALSE;
  333. }
  334. mysql_free_result($result);
  335. // DETERMINE WETHER TO SEND AN EMAIL TO THE DROPSHIPPER (Mike) FOR A GIFT CERTIFICATE
  336. $sql_hc = "SELECT co.coCartOption FROM orders o, cart c, cartoptions co
  337. WHERE o.ordID = c.cartOrderID
  338. AND c.cartID = co.coCartID
  339. AND o.ordID = " . $sorderid;
  340. $res_hc = mysql_query($sql_hc);
  341. $ctr_email=0;
  342. $ctr_card=0;
  343. while($row_hc=mysql_fetch_assoc($res_hc)) {
  344. if($row_hc['coCartOption'] == 'Email') {
  345. $ctr_email++;
  346. }elseif($row_hc['coCartOption'] == 'Card via Mail') {
  347. $ctr_card++;
  348. }
  349. }
  350. if($ctr_email > 0) {
  351. if($ctr_card <= 0) {
  352. $sendmanufemail=FALSE;
  353. }
  354. }
  355. $google_form='';
  356. $showshipdate=FALSE;
  357. $saveCustomerDetails=$orderText;
  358. $orderText = $saveHeader . '%digidownloadplaceholder%' . $orderText;
  359. $sSQL = "SELECT cartID, cartProdId,cartProdName,cartProdPrice,cartQuantity,cartOrderID,p_iscert,pDropship".(@$digidownloads==TRUE?',pDownload':'')." FROM cart INNER JOIN products ON cart.cartProdId=products.pID WHERE cartOrderID='" . mysql_real_escape_string($sorderid) . "'";
  360. // Blake 12/21/06
  361. if(!empty($_SESSION['neworderID'])) $sSQL .= " OR cartOrderID='" . mysql_real_escape_string($_SESSION['neworderID']) . "'";
  362. $sSQL .= " ORDER BY pDropship";
  363. //
  364. //echo $sSQL;
  365. $result = mysql_query($sSQL) or print(mysql_error());
  366. $numProdsCart=mysql_num_rows($result);
  367. if($numProdsCart > 0){
  368. $old_orderID='';
  369. while($rs = mysql_fetch_assoc($result)){
  370. if(trim($rs["pDownload"]) == "" && trim($rs["p_iscert"]) == 0) $showshipdate=TRUE;
  371. $localhasdownload=FALSE;
  372. if(@$digidownloads==TRUE)
  373. if(trim($rs["pDownload"]) != "") $localhasdownload=TRUE;
  374. $saveCartItems='';
  375. if(!empty($_SESSION['neworderID']) && $old_orderID!=$rs["cartOrderID"]) $saveCartItems = $emlNl . $rs["cartOrderID"] . $emlNl;
  376. $saveCartItems .= "--------------------------" . $emlNl;
  377. $saveCartItems .= $xxPrId . ": " . $rs["cartProdId"] . $emlNl;
  378. $saveCartItems .= $xxPrNm . ": " . $rs["cartProdName"] . $emlNl;
  379. $saveCartItems .= $xxQuant . ": " . $rs["cartQuantity"] . $emlNl;
  380. $orderText .= $saveCartItems;
  381. //changed by blake 6-13-06
  382. $down_usr_pass='';
  383. if($localhasdownload==TRUE) {
  384. $sql_d="SELECT * FROM digitaldownloads WHERE orderID=".$rs["cartOrderID"]." AND type='".$rs["cartProdId"]."'";
  385. $result_d=mysql_query($sql_d);
  386. $num_rows_d=mysql_num_rows($result_d);
  387. while($row_d=mysql_fetch_assoc($result_d)){
  388. $allready_has_download=TRUE;
  389. $down_usr_pass.=$emlNl.'License ID: '.$row_d['licenseID'].$emlNl;
  390. $down_usr_pass.='Password: '.$row_d['password'].$emlNl.$emlNl;
  391. }
  392. if($num_rows_d==0) $allready_has_download=FALSE;
  393. for($i=0;$i<$rs["cartQuantity"];$i++) {
  394. if(!$allready_has_download){
  395. $sql_download="SELECT * FROM digitaldownloads WHERE active=1 AND type='".$rs["cartProdId"]."'";
  396. $result_download=mysql_query($sql_download);
  397. $num_rows_download=mysql_num_rows($result_download);
  398. if($num_rows_download>0){
  399. $row_download=mysql_fetch_assoc($result_download);
  400. $down_usr_pass.=$emlNl.'License ID: '.$row_download['licenseID'].$emlNl;
  401. $down_usr_pass.='Password: '.$row_download['password'].$emlNl.$emlNl;
  402. $sql_update="UPDATE digitaldownloads SET active=0, orderID=".$sorderid." WHERE id=".$row_download['id'];
  403. mysql_query($sql_update);
  404. }
  405. }
  406. }
  407. $orderText .= $down_usr_pass;
  408. }
  409. // end change
  410. $theoptions = "";
  411. $theoptionspricediff=0;
  412. $sSQL = "SELECT coOptGroup,coCartOption,coPriceDiff,optRegExp,coExtendShipping FROM cartoptions INNER JOIN options ON cartoptions.coOptID=options.optID WHERE coCartID=" . $rs["cartID"] . " ORDER BY coID";
  413. $result2 = mysql_query($sSQL) or print(mysql_error());
  414. while($rs2 = mysql_fetch_assoc($result2)){
  415. $theoptionspricediff += $rs2["coPriceDiff"];
  416. $optionline = (@$htmlemails==true?"<span style='margin-left: 15px;'>- ":"- - - ") . $rs2["coOptGroup"] . " : " . str_replace(array("\r\n","\n"),array($emlNl,$emlNl),$rs2["coCartOption"]) . ($htmlemails==true ? '</span>' : '');
  417. if(!empty($rs2["coExtendShipping"])){
  418. if($rs2["coExtendShipping"]>19999999) {
  419. $thisyeart=substr($rs2["coExtendShipping"],0,4);
  420. $thismontht=substr($rs2["coExtendShipping"],4,2);
  421. $thisdayt=substr($rs2["coExtendShipping"],6,2);
  422. $optionline .= " (PRE-ORDER. Order will ship after ".$thismontht.'-'.$thisdayt.'-'.$thisyeart.")";
  423. } else $optionline .= " (This option will extend your shipping time by ".$rs2["coExtendShipping"]." days)";
  424. }
  425. $theoptions .= $optionline;
  426. $saveCartItems .= $optionline . $emlNl;
  427. if($rs2["coPriceDiff"]==0 || @$hideoptpricediffs==TRUE)
  428. $theoptions .= $emlNl;
  429. else{
  430. $theoptions .= " (";
  431. if($rs2["coPriceDiff"] > 0) $theoptions .= "+";
  432. $theoptions .= FormatEmailEuroCurrency($rs2["coPriceDiff"]) . ")" . $emlNl;
  433. }
  434. if($rs2["optRegExp"] == "!!") $localhasdownload=FALSE;
  435. }
  436. $orderText .= $xxUnitPr . ": " . (@$hideoptpricediffs==TRUE ? FormatEmailEuroCurrency($rs["cartProdPrice"] + $theoptionspricediff) : FormatEmailEuroCurrency($rs["cartProdPrice"])) . $emlNl;
  437. $orderText .= $theoptions;
  438. if($rs["pDropship"] != 0){
  439. $index=0;
  440. for($index=0; $index<$ndropshippers; $index++){
  441. if($dropShippers[$index][0]==$rs["pDropship"]) break;
  442. }
  443. if($index>=$ndropshippers){
  444. $ndropshippers=$index+1;
  445. $dropShippers[$index][1]="";
  446. }
  447. $dropShippers[$index][0] = $rs["pDropship"];
  448. $dropShippers[$index][1] .= $saveCartItems;
  449. }
  450. if($localhasdownload==TRUE) $hasdownload=TRUE;
  451. $old_orderID=$rs["cartOrderID"];
  452. mysql_free_result($result2);
  453. }
  454. $orderText .= "--------------------------" . $emlNl;
  455. //HCS - DRE 03/02/05 Gift Cert Mod START
  456. if($certstr != "") {
  457. $certarray = explode("|",$certstr);
  458. for ($x = 0; $x < count($certarray);$x++) {
  459. $orderText .= "Gift Certificate Value/Code: ".$certarray[$x].$emlNl;
  460. }
  461. $orderText .= "You can enter the certificate code the next time you order or print a personalized gift certificate here. http://ifrogz.com/order_info.php Enter your email and order number to login. Once logged in click on 'Print Gift Certificates'. " . $emlNl;
  462. $orderText .= "--------------------------" . $emlNl;
  463. }elseif($certorder) {
  464. $orderText .= "Certificate Code(s) will be issued when Payment has been confirmed." . $emlNl;
  465. $orderText .= "--------------------------" . $emlNl;
  466. }
  467. //HCS - DRE 03/02/05 Gift Cert Mod STOP
  468. $orderText .= $xxOrdTot . " : " . FormatEmailEuroCurrency($ordTotal) . $emlNl;
  469. if($shipType != 0) $orderText .= $xxShippg . " : " . FormatEmailEuroCurrency($ordShipping) . $emlNl;
  470. if((double)$ordHandling!=0.0) $orderText .= $xxHndlg . " : " . FormatEmailEuroCurrency($ordHandling) . $emlNl;
  471. if((double)$ordDiscount!=0.0) $orderText .= $xxDscnts . " : " . FormatEmailEuroCurrency($ordDiscount) . $emlNl;
  472. if((double)$ordStateTax!=0.0) $orderText .= $xxStaTax . " : " . FormatEmailEuroCurrency($ordStateTax) . $emlNl;
  473. if((double)$ordCountryTax!=0.0) $orderText .= $xxCntTax . " : " . FormatEmailEuroCurrency($ordCountryTax) . $emlNl;
  474. if((double)$ordHSTTax!=0.0) $orderText .= $xxHST . " : " . FormatEmailEuroCurrency($ordHSTTax) . $emlNl;
  475. $ordGrandTotal = ($ordTotal+$ordStateTax+$ordCountryTax+$ordHSTTax+$ordShipping+$ordHandling)-$ordDiscount;
  476. //HCS - DRE 03/07/05 Gift Cert Mod START
  477. if($pendingamt > 0) {
  478. $ordGrandTotal -= $pendingamt;
  479. if($ordGrandTotal == 0) {
  480. $strsql = "UPDATE orders SET ordStatus=3 WHERE ordID =".$ordID;
  481. mysql_query($strsql);
  482. }
  483. $orderText .= "Gift Certificate Amount Applied to Order: " . FormatEmailEuroCurrency($pendingamt) ." (ending in ".$certend.")". $emlNl;
  484. }
  485. //HCS - DRE 03/07/05 Gift Cert Mod STOP
  486. $orderText .= $xxGndTot . " : " . FormatEmailEuroCurrency($ordGrandTotal) . $emlNl;
  487. //HCS - DRE 03/06/05 Gift Cert Mod START
  488. if($pendingamt > 0) {
  489. if ($remainbal > 0) {
  490. $orderText .= $emlNl."--------------------------".$emlNl;
  491. $orderText .= "Amount Unused on Gift Certificate: " . FormatEmailEuroCurrency($remainbal) ." (ending in ".$certend.")". $emlNl;
  492. $orderText .= "This Gift Certificate will Expire On: " . date("M j, Y", $certexpdt) . $emlNl;
  493. }else{
  494. $orderText .= $emlNl."--------------------------".$emlNl;
  495. $orderText .= "You have exhausted all funds on this Gift Certificate " . $emlNl;
  496. }
  497. }
  498. //HCS - DRE 03/06/05 Gift Cert Mod STOP
  499. eval('global $emailfooter' . $payprovid . ';$emailheader = @$emailfooter' . $payprovid . ';');
  500. if(@$emailheader != "") $orderText .= $emailheader;
  501. if(@$emailfooter != "") $orderText .= $emailfooter;
  502. }else{
  503. $orderText .= "Cannot find order details for order id: " . $sorderid . $emlNl;
  504. }
  505. mysql_free_result($result);
  506. if($hasdownload==TRUE && @$digidownloademail != ""){
  507. $fingerprint = vrhmac($digidownloadsecret, $sorderid . $ordAuthNumber . $ordSessionID);
  508. $fingerprint = substr($fingerprint, 0, 14);
  509. $digidownloademail = str_replace('%orderid%',$ordID,$digidownloademail);
  510. $digidownloademail = str_replace('%password%',$fingerprint,$digidownloademail);
  511. $digidownloademail = str_replace('%nl%',$emlNl,$digidownloademail);
  512. $orderEmailText = str_replace('%digidownloadplaceholder%',$digidownloademail,$orderText);
  513. } else {
  514. $orderEmailText = str_replace('%digidownloadplaceholder%',"",$orderText);
  515. }
  516. $orderText = str_replace('%digidownloadplaceholder%',"",$orderText);
  517. if($sendstoreemail){
  518. $headers = str_replace('%from%',$sEmail,$customheaders);
  519. $headers = str_replace('%to%','orders@ifrogz.com',$headers);
  520. mail('orders@ifrogz.com', $xxOrdStr, $orderEmailText, $headers);
  521. }
  522. // And one for the customer
  523. if($sendcustemail){
  524. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  525. $headers = str_replace('%from%',$sEmail,$customheaders);
  526. $headers = str_replace('%to%',$custEmail,$headers);
  527. $strdaterange='';
  528. if($showshipdate) {
  529. $strrange=$xxTouSooShipping[$ordShipType];
  530. $strdaterange=str_replace("%date_range%",$strrange,$xxTouSooDate);
  531. }
  532. $strfinal=str_replace("%dateorno%",$strdaterange,$xxTouSoo);
  533. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  534. // Mail services
  535. $mailer = new Mailer('AMAZON_IFROGZ', 'GMAIL', 'SEND_MAIL');
  536. // Sender
  537. $mailer->set_sender(new EmailAddress($sEmail));
  538. $mailer->set_reply_to(new EmailAddress('support@ifrogz.com', 'iFrogz Customer Service'));
  539. // Recepients
  540. $mailer->add_recipient(new EmailAddress($custEmail));
  541. // Subject
  542. $mailer->set_subject($xxTnxOrd);
  543. // Message
  544. $mailer->set_content_type('text/html');
  545. $mailer->set_message($strfinal . $emlNl . $emlNl . $orderEmailText);
  546. // Send
  547. $mailer->send();
  548. }
  549. // Drop Shippers
  550. if($sendmanufemail){
  551. for($index=0; $index < $ndropshippers; $index++){
  552. if(@$dropshipsubject=="") $dropshipsubject="We have received the following order";
  553. $sSQL = "SELECT dsEmail,dsAction FROM dropshipper WHERE dsID=" . $dropShippers[$index][0];
  554. $result = mysql_query($sSQL) or print(mysql_error());
  555. if($rs = mysql_fetch_assoc($result)){
  556. if(($rs["dsAction"] & 1)==1 || $sendmanufemail==2){
  557. $saveHeader = "";
  558. $saveFooter = "";
  559. $saveHeader .= @$dropshipheader;
  560. eval('global $dropshipheader' . $dropShippers[$index][0] . ';$emailheader = @$dropshipheader' . $dropShippers[$index][0] . ';');
  561. if($emailheader != "") $saveHeader .= $emailheader;
  562. eval('global $dropshipfooter' . $dropShippers[$index][0] . ';$saveFooter = @$dropshipfooter' . $dropShippers[$index][0] . ';');
  563. $saveFooter .= @$dropshipfooter;
  564. $headers = str_replace('%from%','orders@ifrogz.com',$customheaders);
  565. $headers = str_replace('%to%','dropship@ifrogz.com',$headers);
  566. mail('dropship@ifrogz.com', $dropshipsubject, $saveHeader . $saveCustomerDetails . $dropShippers[$index][1] . $saveFooter, $headers);
  567. //mail('dropship@ifrogz.com', 'A dropship order has been placed on ifrogz', $saveHeader . $saveCustomerDetails . $dropShippers[$index][1] . $saveFooter, $headers);
  568. }
  569. }
  570. }
  571. }
  572. if($sendaffilemail){
  573. if($affilID != ""){
  574. $sSQL = "SELECT affilEmail,affilInform FROM affiliates WHERE affilID='" . mysql_real_escape_string($affilID) . "'";
  575. $result = mysql_query($sSQL) or print(mysql_error());
  576. if($rs = mysql_fetch_assoc($result)){
  577. if((int)$rs["affilInform"]==1){
  578. $affiltext = $xxAff1 . " " . FormatEmailEuroCurrency($ordTotal-$ordDiscount) . ".".$emlNl.$emlNl.$xxAff2.$emlNl.$emlNl.$xxThnks.$emlNl;
  579. $headers = str_replace('%from%',$sEmail,$customheaders);
  580. $headers = str_replace('%to%',trim($rs["affilEmail"]),$headers);
  581. mail(trim($rs["affilEmail"]), $xxAff3, $emlNl . $affiltext, $headers);
  582. }
  583. }
  584. mysql_free_result($result);
  585. }
  586. }
  587. if($doshowhtml){
  588. ?>
  589. <style type="text/css">
  590. <!--
  591. -->
  592. </style>
  593. <div id="cart_nav"><img src="/lib/images/new_images/subnav_gray_13.gif" alt="View Order" /><img src="/lib/images/new_images/subnav_gray_15.gif" alt="Customer Info" /><img src="/lib/images/new_images/subnav_gray_17.gif" alt="Final Review" /><img src="/lib/images/new_images/subnav_gray_19.gif" alt="Confirmation" /><img src="/lib/images/new_images/subnav_green_21.gif" alt="View Receipt" /></div>
  594. <table border="0" cellspacing="<?php print $maintablespacing?>" cellpadding="<?php print $maintablepadding?>" width="<?php print $maintablewidth?>" bgcolor="<?php print $maintablebg?>" align="center">
  595. <tr>
  596. <td width="100%">
  597. <table width="<?php print $innertablewidth?>" border="0" cellspacing="<?php print $innertablespacing?>" cellpadding="<?php print $innertablepadding?>" bgcolor="<?php print $innertablebg?>">
  598. <?php //if(@$digidownloads!=TRUE){ ?>
  599. <tr>
  600. <td width="100%" align="left">
  601. <h2>Order Placed Successfully</h2>
  602. <?php if(@$digidownloads && $hasdownload) echo '<div style="font-size: 16px;color:#9F0000;font-weight:bold;">Please scroll to the bottom of the page to download your software.</div>';?>
  603. <div style="margin-bottom: 10px; padding: 0">
  604. <p style="font-size: 16px"><span style="font-weight:bold">Thank You for shopping
  605. at ifrogz!</span> The ordering process is now complete. Please
  606. read the following information about your order.</p>
  607. </div>
  608. <div style="border: 1px solid #888; padding: 0; margin-top: 0">
  609. <div style="float:left; width: 400px; margin: 20px 0 20px 20px">
  610. <h2>YOUR ORDER
  611. HAS BEEN RECEIVED.</h2>
  612. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">Your order has been
  613. received and will be processed as soon as payment is verified.</p>
  614. <? if(!empty($_SESSION['neworderID'])){?>
  615. <h2>Your Order Will Be Shipped in Two Shipments. Order Numbers are</h2>
  616. <h3><?=$orderID2?>,<?=$_SESSION['neworderID']?></h3>
  617. <? } else { ?>
  618. <h2>Your Order Numbers is</h2>
  619. <h3><?=$orderID2?></h3>
  620. <? } ?>
  621. <? if(!empty($_SESSION['neworderID'])){?>
  622. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">We will send your products in two separate orders because they will be shipped from two of our warehouses. Please make a note
  623. of these number in the event that you need to contact us about your orders.</p>
  624. <? } else { ?>
  625. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">Please make a note
  626. of this number in the event that you need to contact us about your order.</p>
  627. <? } ?>
  628. <h2>Your Delivery Date</h2>
  629. <h3><!--<span style="color: #000;">-->
  630. Delivery Date:<!--</span>--> <?=date("M j, Y",$delivery['deliveryDate'])?></h3>
  631. <?php
  632. if($delivery['extended'] > 0) {
  633. if($delivery['messageToUse'] == 'custom screen') {
  634. ?>
  635. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">Your order contains a custom screen. It will
  636. take an additional <?=$delivery['extended']?> business days to produce your custom screen before your
  637. order will ship. When it ships, your order will ship via <?=$delivery['method']?> and will take
  638. <?=$delivery['days_to_arrive']?> business days to arrive.</p>
  639. <?php
  640. }elseif($delivery['messageToUse'] == 'stock') {
  641. ?>
  642. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">Your order contains a back-ordered item. It will
  643. take an additional <?=$delivery['extended']?> business days before your order will ship. When it ships,
  644. it will ship via <?=$delivery['method']?> and will take <?=$delivery['days_to_arrive']?> to arrive.</p>
  645. <?php
  646. }
  647. }
  648. ?>
  649. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">You should receive your
  650. order in the mail by this date. You will also receive an e-mail with your tracking
  651. number once we get your tracking number.</p>
  652. </div>
  653. <div style="float:right; width: 400px; margin: 20px 20px 4px 0">
  654. <h2>Your Receipt</h2>
  655. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">You have been sent
  656. an e-mail to the address you provided containing your order information.
  657. If you would like an invoice, you can print one from our <a href="http://www.ifrogz.com/order_info.php" style="font-size: 14px">invoice</a> page.</p>
  658. <h2>Your Order Status</h2>
  659. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">We keep track of
  660. your order in realtime! If you would like to know what the status of your
  661. order is, visit our <a href="http://www.ifrogz.com/order_info.php" style="font-size: 14px">tracking</a>
  662. page.</p>
  663. <h2>We're Here for You</h2>
  664. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">ifrogz will
  665. provide you with the best service possible. If you have any questions or
  666. concerns regarding your order, please contact us at support@ifrogz.com
  667. or at the phone number below.</p>
  668. <h2 style="text-align: left; margin:0 0 10px 0;">Your Shopping Cart Has Been
  669. Emptied</h2>
  670. <p style="margin:0 0 10px 0; padding:0; font-size: 14px">The items you purchased
  671. have been removed.</p>
  672. <!-- <h2 style="text-align: left; margin:0 0 10px 0;">Want Individual Bands?</h2>
  673. <p style="margin:0 0 10px 0; padding:0; font-size: 14px"><a href="http://bandsonhand.com" title="Bands On Hand">BandsonHand.com</a> carries 100% silicone bracelets in-stock so you don't have to wait. Choose a category and find a band that meets your needs. Order individual bands or groups of bands. All our bands are in-stock and guaranteed to ship the next business day after you order.</p>
  674. -->
  675. </div>
  676. <div style="clear: both"></div>
  677. </div>
  678. </td>
  679. </tr>
  680. <?php //} ?>
  681. </table>
  682. </td>
  683. </tr>
  684. </table>
  685. <?php
  686. }
  687. /* print $google_form; */
  688. }
  689. ?>