Esempio n. 1
0
 public function updateAction()
 {
     $array = array();
     $connectorClient = new SAPConnectorClient();
     $sapSupplierContactEmployeeCollection = new SapSupplierContactEmployeeCollection($array);
     $sapSupplierAddressCollection = new SapSupplierAddressCollection($array);
     $params = $this->getRequest()->getParams();
     $supplier = SapSupplierFactory::createFromArray($params);
     // 		echo '<pre>';
     // 		print_r($supplier);
     // 		die;
     $supplier->setConsistency(SapSupplierQuery::create()->findByPK($supplier->getCardCode())->getConsistency());
     $supplier->setTime(SapSupplierQuery::create()->findByPK($supplier->getCardCode())->getTime());
     $supplier->setQuality(SapSupplierQuery::create()->findByPK($supplier->getCardCode())->getQuality());
     $address = SapSupplierAddressFactory::createFromArray($params);
     $sapSupplierAddressCollection->append($address);
     foreach ($params['contact'] as $contact) {
         if (!empty($contact['FirstName'])) {
             $contactEmployee = SapSupplierContactEmployeeFactory::createFromArray($contact);
             $sapSupplierContactEmployeeCollection->append($contactEmployee);
             unset($contactEmployee);
         }
     }
     $supplier->setAddresses($sapSupplierAddressCollection);
     $supplier->setContacts($sapSupplierContactEmployeeCollection);
     $result = $connectorClient->UpdateSupplier($supplier);
     if ($result->SapProveedorResult->success) {
         $setupForm = 'SetupForm';
         $profileForm = 'ProfileForm';
         $auditReport = 'AuditReport';
         $this->getSupplierCatalog()->beginTransaction();
         $this->savefileAction($setupForm, SapSupplier::$FileTypes[$setupForm], $supplier->getCardcode());
         $this->savefileAction($profileForm, SapSupplier::$FileTypes[$profileForm], $supplier->getCardcode());
         $this->savefileAction($auditReport, SapSupplier::$FileTypes[$auditReport], $supplier->getCardcode());
         // 			print_r(SupplierFileQuery::create()->whereAdd(SupplierFile::ID_SUPPLIER, $sapSupplier->getCardcode())->find()->toArray());
         $this->getSupplierCatalog()->commit();
         $this->setFlash("ok", $this->i18n->_($result->SapProveedorResult->message));
     } else {
         $this->setFlash("error", $this->i18n->_($result->SapProveedorResult->message));
         $this->_redirect('supplier/list');
     }
     $this->setFlash("ok", $this->i18n->_("The supplier " . $supplier->getIdSupplier() . " has been modified"));
     $this->_redirect('supplier/list');
 }
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\SapSupplierAddress
  */
 protected function makeBean($resultset)
 {
     return SapSupplierAddressFactory::createFromArray($resultset);
 }