public function mailerAdmin($idOrder, $key, $userTo) { $mail = new PaymentGateway_HtmlMail(); $tblSetting = new Kutu_Core_Orm_Table_PaymentSetting(); $template = $tblSetting->fetchAll($tblSetting->select()->where("settingKey = '{$key}'")); $tblOrder = new Kutu_Core_Orm_Table_Order(); $tbluser = new Kutu_Core_Orm_Table_User(); $tblOrderDetail = new Kutu_Core_Orm_Table_OrderDetail(); $tblSetting = new Kutu_Core_Orm_Table_PaymentSetting(); $lgsMail = $tblSetting->fetchAll($tblSetting->select()->where("settingKey = 'paypalBusiness'")); $userDetailInfo = $tbluser->userInfoOrder($idOrder); $rowset = $tblOrder->getOrderAndStatus($idOrder); $rowsetDetail = $tblOrderDetail->fetchAll($tblOrderDetail->select()->where("orderId = " . $idOrder)); $tblConfirm = new Kutu_Core_Orm_Table_PaymentConfirmation(); if ($rowset[0]->orderStatus == 6) { $status = 'rejected'; } else { $status = 'confirmed'; } $unConfirmed = $tblConfirm->fetchAll($tblConfirm->select()->where("confirmed =0 AND orderId = " . $idOrder)); echo '<pre>'; //print_r($userDetailInfo); echo '</pre>'; $detail = "ORDER ID : " . $idOrder . '<br/>' . 'Detail : <br/><blockquote><ol>'; foreach ($rowsetDetail as $row) { $detail .= '<li><ul> <li>Document Name: ' . $row->documentName . '</li> <li>Quantity : ' . $row->qty . '</li> <li>Price : USD ' . number_format($row->price, 2) . ' </li> <li>Tax : ' . number_format($row->tax, 2) . ' %</li> <li>Final Price : ' . number_format($row->finalPrice, 2) . '</li> </ul></li>'; } $detail .= '</ol><blockquote><br />'; //print_r($detail); $sMailSource = $template[0]->note; if ($userTo == 'admin') { $sMailEmailTo = $lgsMail[0]->settingValue; $sMailEmailFrom = $userDetailInfo[0]->email; $link = '<a href="' . KUTU_ROOT_URL . '/admin/store/detailOrder/id/' . $idOrder . '">here</a>'; } else { $sMailEmailTo = $userDetailInfo[0]->email; $sMailEmailFrom = $lgsMail[0]->settingValue; $link = '<a href="' . KUTU_ROOT_URL . '/site/store_payment/detail/id/' . $idOrder . '">here</a>'; } $sMailSubject = "Confirmation for user payment"; $sMailHeader = ''; $aMailDataSet = array('PAYMENTDATE' => $unConfirmed[0]->paymentDate, 'PAIDTIME' => $unConfirmed[0]->paymentDate, 'PAYMENT' => $rowset[0]->paymentMethod, 'DESCRIPTION' => $detail, 'TOTALORDER' => $rowset[0]->orderTotal, 'ORDERTIME' => $rowset[0]->datePurchased, 'INVOICE' => $rowset[0]->invoiceNumber, 'METHOD' => $rowset[0]->paymentMethod, 'LINK' => $link, 'STATUS' => $status); $mail->SendFileMail($sMailSource, $sMailEmailTo, $sMailSubject, $sMailEmailFrom, $sMailHeader, $aMailDataSet); }
public function payconfirmnoAction() { //print_r($this->_request->getParams()); $id = $this->_request->getParam('id'); //$method = $this->_request->getParam('method'); /*if($this->_request->getParam('method') == 'bank'){ $method = 1; }else{ $method = 5; }*/ $this->view->idOrder = $id; $this->view->warn = ''; if ($this->_request->isPost('adminNotes') == true) { if (strlen($this->_request->getParam('adminNotes')) == 0) { $this->view->warn = '<div class="error"> Please insert some notes</div>'; } else { $id = $this->_request->getParam('id'); $method = 6; $tblOrder = new Kutu_Core_Orm_Table_Order(); $tblHistory = new Kutu_Core_Orm_Table_OrderHistory(); $tblConfirm = new Kutu_Core_Orm_Table_PaymentConfirmation(); //echo $method; //select payment date from paymentconfirmation $date = $tblConfirm->fetchAll($tblConfirm->select()->where("orderId = " . $id . " AND confirmed = 0")); //$data['paidDate'] = @$date[0]->paymentDate; //update order $data['orderStatus'] = $method; $data['adminNotes'] = $this->_request->getParam('adminNotes'); $tblOrder->update($data, "orderId = " . $id); //update paymentconfirmation $dataConfirm['confirmed'] = 1; $dataConfirm['adminNotes'] = $this->_request->getParam('adminNotes'); $tblConfirm->update($dataConfirm, "orderId = " . $id); //add history $dataHistory = $tblHistory->fetchNew(); //history data $dataHistory['orderId'] = $id; $dataHistory['orderStatusId'] = $method; $dataHistory['dateCreated'] = date('Y-m-d'); $dataHistory['userNotified'] = 1; $dataHistory['note'] = 'rejected'; $dataHistory->save(); $mod = new App_Model_Store_Mailer(); $mod->sendReceiptToUser($id, 'Bank Transfer', "REJECTED", 1); //redirect to confirmation page $this->_helper->redirector('confirm'); } } }