Ejemplo n.º 1
0
 /**
  * @param integer $id
  * @param Base_Form_Abstract $form
  * @throws Logic_Ws_Exception
  * @return void
  */
 public function updateClient($id, Base_Form_Abstract $form)
 {
     $values = $form->getValues();
     $ipAddress = $values['ip_address'];
     unset($values['ip_address']);
     if (empty($values['code'])) {
         unset($values['code']);
     }
     $clientIpModel = new WsClientHasWsSaveip();
     try {
         if (intval($values['shipping_type']) === Logic_Ws_ServiceSet_ServiceSet::SHIPPING_TYPE_API && !empty($values['code'])) {
             $values['code'] = sha1($values['code']);
         }
         $oldRow = $this->findOne($id);
         $oldRow->setFromArray($values);
         $oldRow->save();
         $clientIpModel->deleteIP($id);
         foreach ($ipAddress as $val) {
             if (intval($val) > 0) {
                 $clientIpModel->insertClientIP(array('ws_client_id' => $id, 'ws_saveip_id' => $val));
             }
         }
     } catch (Exception $e) {
         throw new Logic_Ws_Exception($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * 
  * @param Base_Form_Abstract $form
  * @param type $id
  * @throws Logic_Ws_Exception
  */
 public function updateIP(Base_Form_Abstract $form, $id)
 {
     $values = $form->getValues();
     $clients = $values['clients'];
     unset($values['clients']);
     $clientIpModel = new WsClientHasWsSaveip();
     try {
         $oldRow = $this->findOne($id);
         $oldRow->setFromArray($values);
         $oldRow->save();
         $clientIpModel->deleteClients($id);
         foreach ($clients as $val) {
             $clientIpModel->insertClientIP(array('ws_client_id' => $val, 'ws_saveip_id' => $id));
         }
     } catch (Exception $e) {
         throw new Logic_Ws_Exception($e->getMessage());
     }
 }