function adminsetselectedorderAction() { $type = $this->_request->getParam('type'); if ($type == 'orderState') { $idStr = $this->_request->getParam('orderids'); $idStrArray = explode(',', $idStr); $productOrderModel = new ProductOrder(); foreach ($idStrArray as $idAndState) { if (null == $idAndState || '' == $idAndState) { continue; } $idAndStateArray = explode('@', $idAndState); $productOrder = $productOrderModel->fetchRow('id = ' . $idAndStateArray[0]); // consumer cancel order if ($productOrder->state == 'CANCEL') { continue; } // confirm used point in table 'reward_point_transaction_record' $rewardPointTransactionRecordModel = new RewardPointTransactionRecord(); $rewardPointTransactionRecord = $rewardPointTransactionRecordModel->fetchRow('id = ' . $productOrder->reward_point_transaction_record_id); if ($rewardPointTransactionRecord == null) { continue; } else { $productModel = new Product(); $product = $productModel->fetchRow('id = ' . $productOrder->product_id); if ($product == null) { continue; } else { if ($idAndStateArray[1] == 'UNAPPROVED') { $rewardPointTransactionRecord->point_amount = 0; } } $rewardPointTransactionRecord->save(); } // change order state $currenttime = date("Y-m-d H:i:s"); $productOrder->state = $idAndStateArray[1]; $productOrder->handle_date = $currenttime; $productOrder->save(); } } $this->_helper->json('Success'); }
function adminsaveurlreportstateAction() { $type = $this->_request->getParam('type'); $db = Zend_Registry::get('db'); if ($type == 'reportState') { $idStr = $this->_request->getParam('reportids'); $idStrArray = explode(',', $idStr); $reportIdArray = array(); $i = 0; $config = Zend_Registry::get('config'); $smtpSender = new Zend_Mail_Transport_Smtp($config->smtp->report->mail->server, array('username' => $config->smtp->report->mail->username, 'password' => $config->smtp->report->mail->password, 'auth' => $config->smtp->report->mail->auth, 'ssl' => $config->smtp->report->mail->ssl, 'port' => $config->smtp->report->mail->port)); // $smtpSender = new Zend_Mail_Transport_Smtp( // 'smtp.163.com',array( // 'username'=>'*****@*****.**', // 'password'=>'19990402', // 'auth'=>'login')); Zend_Mail::setDefaultTransport($smtpSender); foreach ($idStrArray as $idAndState) { if ($idAndState == '') { continue; } $idAndStateArray = explode('@', $idAndState); if ($idAndStateArray[1] == 'NEW') { continue; } if ($idAndStateArray[1] == 'APPROVED') { $urlreportModel = new UrlReport(); $row = $urlreportModel->fetchRow('id = ' . $idAndStateArray[0]); if ($row->state != 'NEW') { continue; } $row->state = $idAndStateArray[1]; if ($row->reward_point_transaction_record_id == null || $row->reward_point_transaction_record_id == '') { $rewardModel = new RewardPointTransactionRecord(); $reward = $rewardModel->createRow(); $reward->consumer_id = $idAndStateArray[2]; $reward->date = date("Y-m-d H:i:s"); $reward->transaction_id = 8; $reward->point_amount = 300; $row->reward_point_transaction_record_id = $reward->save(); } else { $rewardModel = new RewardPointTransactionRecord(); $reward = $rewardModel->fetchRow('id = ' . $row->reward_point_transaction_record_id); if ($reward != null) { $reward->date = date("Y-m-d H:i:s"); $reward->point_amount = 300; $reward->save(); } } $row->save(); //2011-05-13 change the rank of consumer $rankModel = new Rank(); $rankModel->changeConsumerRank($idAndStateArray[1]); } if ($idAndStateArray[1] == 'UNAPPROVED') { $urlreportModel = new UrlReport(); $row = $urlreportModel->fetchRow('id = ' . $idAndStateArray[0]); if ($row == null) { continue; } if ($row->reward_point_transaction_record_id != null && $row->reward_point_transaction_record_id != '') { $rewardModel = new RewardPointTransactionRecord(); $reward = $rewardModel->fetchRow('id = ' . $row->reward_point_transaction_record_id); if ($reward != null) { $db2 = $rewardModel->getAdapter(); $where = $db2->quoteInto('id = ?', $row->reward_point_transaction_record_id); $rows_affected = $rewardModel->delete($where); } } $db2 = $urlreportModel->getAdapter(); $where = $db2->quoteInto('id = ?', $idAndStateArray[0]); $rows_affected = $urlreportModel->delete($where); } $consumerModel = new Consumer(); $consumer = $consumerModel->fetchRow('id = ' . $idAndStateArray[2]); //send mail... if ($consumer->email == '') { continue; } $mail = new Zend_Mail('utf-8'); if ($consumer->language_pref != null && $consumer->language_pref == 'en') { $emailSubject = $this->view->translate('Admin_Reply_WOM_URLReport_Subject_en'); $emailBody = $this->view->translate('Admin_Reply_WOM_URLReport_Body_en'); } else { $emailSubject = $this->view->translate('Admin_Reply_WOM_URLReport_Subject_zh'); $emailBody = $this->view->translate('Admin_Reply_WOM_URLReport_Body_zh'); } $stringChange = array('?USERNAME?' => $consumer->name, '?YOURSTORY?' => $row->url, '?MYRESPONSE?' => $idAndStateArray[3]); $emailBody = strtr($emailBody, $stringChange); $langNamespace = new Zend_Session_Namespace('Lang'); if ($langNamespace->lang == 'en' || $langNamespace->lang == 'EN') { $mail->setSubject($emailSubject); } else { $mail->setSubject("=?UTF-8?B?" . base64_encode($emailSubject) . "?="); } $mail->setBodyText($emailBody); $mail->addTo($consumer->email); $mail->setFrom($config->smtp->report->mail->username, $this->view->translate('Wildfire')); // $mail->setFrom('*****@*****.**',$this->view->translate('Wildfire')); $mail->send(); // save email $urlreportreplyModel = new UrlReportReply(); $urlreportreply = $urlreportreplyModel->createRow(); $urlreportreply->date = date("Y-m-d H:i:s"); $urlreportreply->subject = $emailSubject; $urlreportreply->content = $idAndStateArray[3]; $urlreportreply->from = $config->smtp->report->mail->username; $urlreportreply->to = $consumer->email; $urlreportreply->url_report_id = $row->id; //2011-04-08 ham.bao separate the sessions with admin $urlreportreply->admin_id = $this->_currentAdmin->id; $urlreportreply->save(); } } }
function deleteorderAction() { $this->view->title = $this->view->translate("Wildfire") . " - " . $this->view->translate("GIFT_DELETE_ORDER"); $orderid = $this->_request->getParam('orderid'); $productorderModel = new ProductOrder(); $order = $productorderModel->fetchRow('id = ' . $orderid); if ($order == null || $order->state != 'NEW' || $order->consumer_id != $this->_currentUser->id) { $this->view->message = $this->view->translate("Gift_delete_order_fail"); return; } else { // reward_point_transaction_record table $rewardPointTransactionRecordModel = new RewardPointTransactionRecord(); $rewardPointTransactionRecord = $rewardPointTransactionRecordModel->fetchRow('id = ' . $order->reward_point_transaction_record_id); $rewardPointTransactionRecord->point_amount = 0; $rewardPointTransactionRecord->save(); // product_order table $order->state = 'CANCEL'; $order->save(); // roll back... } $this->view->message = $this->view->translate("Gift_delete_order_successfully"); }