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


PHP Customers::saveAll方法代码示例

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


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

示例1: 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

示例2: processAction

 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/customers/process");
     // Add the customer custom attributes
     $form = CustomAttributes::getElements($form);
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/customers/list", "label" => $this->translator->translate('List'), "params" => array('css' => null)), array("url" => "/admin/customers/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     try {
         // Check if we have a POST request
         if (!$request->isPost()) {
             return $this->_helper->redirector('list', 'customers', 'admin');
         }
         if ($form->isValid($request->getPost())) {
             $params = $request->getPost();
             $area = intval($params['area']);
             if ($area != 0) {
                 $province = Provinces::find($area);
                 $area = $province->code;
                 $params['area'] = $area;
             }
             $id = Customers::saveAll($params, $request->getParam('customer_id'));
             CustomAttributes::saveElementsValues($form->getSubForm('attributes')->getValues(), $request->getParam('customer_id'), "customers");
             $this->_helper->redirector('edit', 'customers', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         } else {
             $this->view->form = $form;
             $this->view->title = $this->translator->translate("Customer details");
             $this->view->description = $this->translator->translate("Here you can edit the customer details.");
             return $this->render('applicantform');
         }
     } catch (Exception $e) {
         $this->_helper->redirector('edit', 'customers', 'admin', array('id' => $id, 'mex' => $e->getMessage(), 'status' => 'danger'));
     }
 }
开发者ID:moay,项目名称:shineisp,代码行数:40,代码来源:CustomersController.php


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