{
QString mail=QInputDialog::getText(this, tr("Change Mail Address"), tr("Please enter the mail address for this customer to log into the web portal:"),QLineEdit::Normal, m_mail->text());
if(mail!=""){
+ MTChangeCustomerMail ccm=req->queryChangeCustomerMail(m_cust.customerid(),mail);
+ if(ccm.hasError()){
+ QMessageBox::warning(this,tr("Warning"),tr("Unable to set new email: %1").arg(ccm.errorString()));
+ return;
+ }
m_mail->setText(mail);
m_cust.setemail(mail);
}
</Transaction>
<Transaction name="ChangeCustomer">
- <Doc>changes customer data</Doc>
+ <Doc>changes customer data (except online data)</Doc>
<Input>
<Var name="customer" type="Customer"/>
</Input>
<Var name="customer" type="Customer"/>
</Output>
</Transaction>
+
+ <Transaction name="ChangeCustomerMail">
+ <Doc>changes customer login data</Doc>
+ <Input>
+ <Var name="customerid" type="int"/>
+ <Var name="email" type="string"/>
+ </Input>
+ <Call lang="php" method="WOCustomer::changeCustomerMail($this);"/>
+ <Output>
+ <Var name="customer" type="Customer"/>
+ </Output>
+ </Transaction>
<Transaction name="DeleteCustomer">
<Doc>deletes a customer - usually by merging info into another customer</Doc>
//create customer
$cc->toTablecustomer($ct);
$ct->revert("passwd");
+ $ct->revert("email");
$ct->revert("rstcode");
$ct->revert("rsttill");
if($ct->isChanged())$ct->update();
$trans->setcontacttype(WOContactType::fromTablecontacttype($tab));
}
+ /**called from ChangeCustomerMail transaction*/
+ public static function changeCustomerMail($trans)
+ {
+ global $db;
+ $cc=$trans->getcustomerid();
+ $ct=WTcustomer::getFromDB($cc);
+ if(!is_a($ct,"WTcustomer")){
+ $trans->abortWithError(tr("Customer does not exist in the database."));
+ return;
+ }
+ //try to set new mail
+ $ct->email=$trans->getemail();
+ if(!$ct->update()){
+ $trans->abortWithError(tr("This email already exists in the database."));
+ return;
+ }
+ //set return value
+ $trans->setcustomer(WOCustomer::fromTablecustomer($ct));
+ }
+
///the ResetCustomerPassword transaction
public static function resetPassword($trans)
{