/** * Invia la mail di notifica cambio stato al cliente * @param string $result * @param array $order * @param string $status * @param string $esito * @return boolean TRUE se spedizione avvenuta con successo */ private function mail_to_customer($result, $order, $status, $esito) { $subject = $this->LANG->_('MAIL_' . $result . '_CUSTOMER_SUBJECT'); $textbody = $this->LANG->_('MAIL_' . $result . '_CUSTOMER_BODY'); $htmlbody = $this->LANG->_('MAIL_' . $result . '_CUSTOMER_BODY_HTML'); $info = ProPayment_VMHelper::getOrderUserInfo($order["virtuemart_order_id"]); $email = $info->email; $order_status_name = ProPayment_VMHelper::getStatusName($status); $tags = array('{title}' => $this->MODULE->title, '{order_number}' => $order["order_number"], '{order_status_name}' => $order_status_name, '{riga_esito}' => $esito != "" ? $this->LANG->_('ESITO') . ': ' . $esito : ''); $textbody = str_replace(array_keys($tags), array_values($tags), $textbody); $htmlbody = str_replace(array_keys($tags), array_values($tags), $htmlbody); if ($htmlbody != "") { $isHtml = true; $body = $htmlbody; $altbody = $textbody; } else { $isHtml = false; $body = $textbody; $altbody = ""; } $result = ProPayment_VMHelper::sendMail($this->config['BP_EMAIL_FROM'], $this->config['BP_EMAIL_FROMNAME'], $email, $subject, $body, $altbody, $isHtml); if (JError::isError($result)) { $this->errorLog("Errore nell'invio della notifica al cliente (" . $email . "): " . $result->toString()); return FALSE; } elseif (empty($result)) { $this->errorLog("Errore nell'invio della notifica al cliente (" . $email . ")."); return FALSE; } else { return TRUE; } }
/** * Funzione per recuperare i dati utente (di fatturazione o spedizione * @param int $virtuemart_order_id * @param boolean $shipping * @return PPUserInfo */ public static function getOrderUserInfo($virtuemart_order_id, $shipping = false) { $db = JFactory::getDBO(); $q = "SELECT u.*, s.state_2_code, c.country_2_code "; $q .= "FROM #__virtuemart_order_userinfos u "; $q .= "LEFT JOIN #__virtuemart_states s ON (u.virtuemart_state_id=s.virtuemart_state_id) "; $q .= "LEFT JOIN #__virtuemart_countries c ON (u.virtuemart_country_id=c.virtuemart_country_id) "; $q .= "WHERE address_type='" . ($shipping ? "ST" : "BT") . "' AND virtuemart_order_id='{$virtuemart_order_id}'"; $db->setQuery($q); $data = $db->loadAssoc(); if ($data == null && $shipping) { // se non c'è indirizzo di spedizione, uso quello di fatturazione return ProPayment_VMHelper::getOrderUserInfo($virtuemart_order_id, false); } else { // creo l'ogggetto PPUserInfo $userinfo = new PPUserInfo(); $userinfo->company = $data['company']; $userinfo->name = $data['first_name'] . " " . $data['last_name']; $userinfo->address_1 = $data['address_1']; $userinfo->address_2 = $data['address_2']; $userinfo->city = $data['city']; $userinfo->state = $data['state_2_code']; $userinfo->country = $data['country_2_code']; $userinfo->zip = $data['zip']; $userinfo->email = $data['email']; $userinfo->phone_1 = $data['phone_1']; $userinfo->phone_2 = $data['phone_2']; $userinfo->fax = $data['fax']; return $userinfo; } }