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


PHP Addresses::AddNew方法代码示例

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


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

示例1: saveAll

 /**
  * Save all the data in the database
  * @param array $data
  * @param integer $id
  */
 public static function saveAll(array $data, $id)
 {
     if (!empty($data) && is_array($data)) {
         if (is_numeric($id)) {
             $customer = Doctrine::getTable('Customers')->find($id);
             if ($customer->customer_id != $id) {
                 return false;
             }
             if ($customer->isp_id != Isp::getCurrentId()) {
                 return false;
             }
             $customer['created_at'] = date('Y-m-d h:i:s');
         } else {
             $customer = new Customers();
         }
         $customer['company'] = $data['company'];
         $customer['firstname'] = $data['firstname'];
         $customer['lastname'] = $data['lastname'];
         $customer['gender'] = $data['gender'];
         if (!empty($data['password'])) {
             $customer['password'] = crypt($data['password']);
         }
         $customer['email'] = $data['email'];
         $customer['birthplace'] = $data['birthplace'];
         $customer['birthdate'] = Shineisp_Commons_Utilities::formatDateIn($data['birthdate']);
         $customer['birthdistrict'] = $data['birthdistrict'];
         $customer['birthcountry'] = $data['birthcountry'];
         $customer['birthnationality'] = $data['birthnationality'];
         $customer['note'] = $data['note'];
         $customer['vat'] = $data['vat'];
         $customer['taxpayernumber'] = $data['taxpayernumber'];
         $customer['status_id'] = $data['status_id'];
         $customer['issubscriber'] = $data['issubscriber'];
         $customer['legalform_id'] = $data['legalform_id'];
         $customer['type_id'] = $data['type_id'];
         $customer['group_id'] = $data['group_id'];
         $customer['issubscriber'] = !empty($data['issubscriber']) ? 1 : 0;
         $customer['taxfree'] = !empty($data['taxfree']) ? 1 : 0;
         $customer['legalform_id'] = $data['legalform_id'];
         $customer['type_id'] = !empty($data['type_id']) ? $data['type_id'] : Null;
         $customer['parent_id'] = !empty($data['parent_id']) ? $data['parent_id'] : Null;
         $customer['isreseller'] = !empty($data['isreseller']) ? $data['isreseller'] : Null;
         $customer['ignore_latefee'] = (bool) $data['ignore_latefee'];
         $customer['language_id'] = $data['language_id'];
         $customer['updated_at'] = date('Y-m-d h:i:s');
         $customer['isp_id'] = Isp::getCurrentId();
         $customer->save();
         // get the customer ID
         $data['customer_id'] = empty($data['customer_id']) ? $customer['customer_id'] : $data['customer_id'];
         // Handle the customer address
         if (!empty($data['address'])) {
             Addresses::AddNew($data);
         }
         // Handle the customer contact
         if (!empty($data['contact'])) {
             Contacts::AddNew(array('contact' => $data['contact'], 'type_id' => $data['contacttypes'], 'customer_id' => $customer['customer_id']));
         }
         // Newsletter OptIn
         if (!empty($data['issubscriber']) && $data['issubscriber'] == 1) {
             NewslettersSubscribers::customer_optIn($customer['customer_id']);
             // Add the customer email in the newsletter list
         } else {
             NewslettersSubscribers::customer_optOut($customer['customer_id']);
             // Remove the customer email from the newsletter subscriber list
         }
         // Save the upload file
         self::UploadDocument($customer['customer_id'], $data['filecategory']);
         return $customer['customer_id'];
     }
     return false;
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:76,代码来源:Customers.php

示例2: update

 public function update($uuid, $params)
 {
     $this->authenticate();
     $form = new Api_Form_CustomerForm(array('action' => '#', 'method' => 'post'));
     if (array_key_exists('countrycode', $params)) {
         $country_id = Countries::getIDbyCode($params['countrycode']);
         if ($country_id == null) {
             throw new Shineisp_Api_Exceptions(400005, ":: 'countrycode' not valid");
             exit;
         }
         unset($params['coutrycode']);
         $params['country_id'] = $country_id;
     }
     if (array_key_exists('provincecode', $params) && $params['provincecode'] != "") {
         $params['area'] = $params['provincecode'];
         unset($params['provincecode']);
     }
     if ($form->isValid($params)) {
         if ($params['status'] == false) {
             $params['status'] = 'disabled';
         }
         $customer = Customers::findWithUuid($uuid);
         if (empty($customer)) {
             return false;
         }
         $customerid = $customer['customer_id'];
         // $data       = explode('/', $params['birthdate']);
         // list( $gg, $mm, $yyyy )  = $data;
         // $params['birthdate']    = $yyyy.'-'.$mm.'-'.$gg;
         foreach ($customer as $name => &$value) {
             if (array_key_exists($name, $params)) {
                 $value = $params[$name];
             }
         }
         $fields = $params;
         unset($fields['address']);
         unset($fields['contact']);
         Customers::saveAll($customerid, $fields);
         $address = array();
         $address['address'] = $params['address'];
         $address['city'] = $params['city'];
         $address['code'] = $params['code'];
         $address['area'] = $params['area'];
         $address['region_id'] = $params['regionid'];
         $address['country_id'] = $params['country_id'];
         $address['customer_id'] = $customerid;
         if ($params['addressid'] != 0) {
             Addresses::AddNew($address, $params['addressid']);
         } else {
             Addresses::AddNew($address);
         }
         if (array_key_exists('contacts', $params) && !empty($params['contacts'])) {
             foreach ($params['contacts'] as $contact) {
                 if ($contact['contact'] == "") {
                     continue;
                 }
                 $c = array();
                 $c['contact'] = $contact['contact'];
                 $c['type_id'] = $contact['contacttypes'];
                 $c['customer_id'] = $customerid;
                 if (intval($contact['idcontact']) != 0) {
                     Contacts::AddNew($c, intval($contact['idcontact']));
                 } else {
                     Contacts::AddNew($c);
                 }
             }
         }
         return true;
     } else {
         $errors = $form->getMessages();
         $message = "";
         foreach ($errors as $field => $errorsField) {
             $message .= "Field '{$field}'<br/>";
             foreach ($errorsField as $error => $describe) {
                 $message .= " => {$error} ({$describe})";
             }
         }
         throw new Shineisp_Api_Exceptions(400004, ":\n{$message}");
         exit;
     }
 }
开发者ID:kokkez,项目名称:shineisp,代码行数:81,代码来源:Customers.php


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