当前位置: 首页>>代码示例>>PHP>>正文


PHP Addresses::findOneByUserId方法代码示例

本文整理汇总了PHP中Addresses::findOneByUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Addresses::findOneByUserId方法的具体用法?PHP Addresses::findOneByUserId怎么用?PHP Addresses::findOneByUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Addresses的用法示例。


在下文中一共展示了Addresses::findOneByUserId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isVATFree

 /**
  * Check if the customer is subject to EU-VAT
  * TODO: add support for multiple invoicing addresses
  * 
  * @param integer $id
  * @return boolean
  * @throws Exception
  */
 public static function isVATFree($id)
 {
     if (!is_numeric($id)) {
         throw new Exception('Customer Id paramenter is mandatory');
     }
     $customer = self::getAllInfo($id);
     // tax free also means vat free
     if (!empty($customer['taxfree']) && $customer['taxfree']) {
         return true;
     }
     $Addresses = Addresses::findOneByUserId($id);
     if (!isset($Addresses->country_id) || !is_numeric($Addresses->country_id)) {
         return false;
     }
     if (empty($customer['vat'])) {
         /*
          * Private
          */
         //* EU country, VAT ok
         return !Countries::isUEbyId($Addresses->country_id);
     } else {
         /*
          * Company
          */
         //* TODO: 82 is Italy. This should not be hardcoded here.
         return $Addresses->country_id != 82 ? true : false;
     }
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:36,代码来源:Customers.php

示例2: processAction

 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/profile/process");
     $request = $this->getRequest();
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index', 'index', 'default');
     }
     if ($form->isValid($request->getPost())) {
         // Get the id
         $id = $this->getRequest()->getParam('customer_id');
         try {
             // Set the new values
             if (is_numeric($id)) {
                 $customer = Doctrine::getTable('Customers')->find($id);
                 $oldCustomer = $customer->toArray();
                 // Get the values posted
                 $params = $form->getValues();
                 $customer->company = $params['company'];
                 $customer->firstname = $params['firstname'];
                 $customer->lastname = $params['lastname'];
                 $customer->email = $params['email'];
                 $customer->birthdate = Shineisp_Commons_Utilities::formatDateIn($params['birthdate']);
                 if (!empty($params['password'])) {
                     $customer->password = MD5($params['password']);
                 }
                 $customer->birthplace = $params['birthplace'];
                 $customer->birthdistrict = $params['birthdistrict'];
                 $customer->birthcountry = $params['birthcountry'];
                 $customer->birthnationality = $params['birthnationality'];
                 $customer->vat = $params['vat'];
                 $customer->taxpayernumber = $params['taxpayernumber'];
                 $customer->type_id = !empty($params['company_type_id']) ? $params['company_type_id'] : NULL;
                 $customer->legalform_id = $params['legalform'];
                 $customer->gender = $params['gender'];
                 // Save the data
                 $customer->save();
                 $id = is_numeric($id) ? $id : $customer->getIncremented();
                 // Manage the address of the customer
                 $address = new Addresses();
                 $mainAddress = $address->findOneByUserId($id);
                 if ($mainAddress) {
                     $address = $mainAddress;
                 }
                 $address->address = $params['address'];
                 $address->city = $params['city'];
                 $address->code = $params['code'];
                 $address->country_id = $params['country_id'];
                 $address->area = $params['area'];
                 $address->customer_id = $id;
                 $address->save();
                 if (!empty($params['contact'])) {
                     $contacts = new Contacts();
                     $contacts->contact = $params['contact'];
                     $contacts->type_id = $params['contacttypes'];
                     $contacts->customer_id = $id;
                     $contacts->save();
                 }
                 // Add or Remove the customer email in the newsletter list
                 Customers::newsletter_subscription($id, $params['newsletter']);
                 $retval = Shineisp_Commons_Utilities::getEmailTemplate('profile_changed');
                 if ($retval) {
                     $subject = $retval['subject'];
                     $subject = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $retval['subject']);
                     // Alert the administrator about the changing of the customer information
                     $body = $retval['template'];
                     $body = str_replace("[user]", $params['firstname'] . " " . $params['lastname'], $body);
                     $body = str_replace("[old]", print_r($oldCustomer, true), $body);
                     $body = str_replace("[new]", print_r($customer->toArray(), true), $body);
                     $isp = Shineisp_Registry::get('ISP');
                     Shineisp_Commons_Utilities::SendEmail($isp->email, $isp->email, null, $subject, $body);
                 }
             }
         } catch (Exception $e) {
             echo $e->getMessage();
             die;
         }
         return $this->_helper->redirector('account', 'profile', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success'));
     } else {
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("Profile details");
         $this->view->description = $this->translator->translate("Update here your details filling the applicant form with all the information about you.");
         return $this->_helper->viewRenderer('applicantform');
     }
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:91,代码来源:ProfileController.php


注:本文中的Addresses::findOneByUserId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。